This post contains a guide on how to update PowerShell to version 7, upgrading from PowerShell v5 to the latest version available.
Staying on top of software updates is a universal best practice, and PowerShell is no exception. Ensuring you are running the latest PowerShell version is vital, especially if you want to leverage the newest features and cmdlets. Imagine running a script only to find out that it contains a command unrecognized on your current PowerShell version.
Upgrading PowerShell from v5 to v7
This step-by-step guide covers checking your current PowerShell version, upgrading to PowerShell v7, and adjusting your default PowerShell version in Windows Terminal.
1. Check PowerShell Version
Determining your current PowerShell version is done by simply running $PSVersionTable in your PowerShell console:
# Check PowerShell Version $PSVersionTable
The resulting output, as illustrated in the screenshot above, provides details about your current PowerShell version. This example shows a running version of Windows PowerShell v5.
2. Upgrade to PowerShell v7
To perform the upgrade we are using Windows Package Manager (winget), which is a Windows command-line package manager that makes managing installations and upgrades a lot easier. This is the recommended method by Microsoft, as stated in the PowerShell Upgrade docs.
# Search for the Microsoft.PowerShell Package using winget winget search Microsoft.PowerShell # Install latest PowerShell Version winget install --id Microsoft.Powershell --source winget
The installation process is straightforward and will seamlessly install PowerShell version 7 with the latest release. You should now close and re-open your Windows Terminal.
3. Change Default PowerShell Terminal
With PowerShell Version 7 now installed on our computer, we should now change our default settings in Windows Terminal.
To do this, click the down arrow and select Settings:
In the Windows Terminal Startup Settings menu, change the Default profile to PowerShell (the black icon):
By making this change we are ensuring every time we open Windows Terminal it will now use PowerShell v7 rather than v5.
Conclusion
Maintaining an up-to-date PowerShell version is crucial for optimal performance and compatibility with the latest features and scripts. To ensure you are on the latest release, visit the Microsoft PowerShell GitHub Releases page and compare your current version. If you find that your version is outdated, upgrading to the latest release is recommended.
One thought on “How to Update PowerShell to Version 7”