If you get a notice that there is a new version of PowerShell, you can update it easily. Sometimes you see an update notice when you open PowerShell.
You can also check the version with a command: $PSVersionTable
$PSVersionTable
Output:
Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.22621
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
The best way to update PowerShell is through the command line, using winget.
To do this, open PowerShell as Administrator.
To download and install the update, open up a PowerShell tab in Terminal. Type or copy and paste the following command at the command line and press Enter. This command will download and install the latest version of PowerShell from Microsoft’s GitHub repository:
winget install --id Microsoft.Powershell --source winget
Note: That command downloads the latest stable PowerShell release. If you want the preview version of PowerShell — which is basically the open beta version — replace Microsoft.Powershell with Microsoft.PowerShell.Preview in the previous command.
winget install --id Microsoft.Powershell.Preview --source winget
Now we can see the new version: