A couple of arbitration mailboxes are corrupt, and we like to make them healthy. It…
How to Install and Update PowerShell 7
Windows PowerShell is installed on Windows systems by default. But that’s Windows PowerShell and not PowerShell. To make the most out of PowerShell, you should upgrade to PowerShell 7. In this article, you will learn how to install and update PowerShell 7.
Table of contents
Windows PowerShell vs PowerShell
There are two PowerShell versions that you need to be aware of:
- Windows PowerShell (version 1.0 – 5.1)
It’s preinstalled on all modern Windows client and server OS releases. It’s not being developed further, and the latest version is 5.1. The executable is powershell.exe.
- PowerShell (version 6 and higher)
It’s not preinstalled on any version of Windows. It’s actively being developed, is much faster, and has better commands available. The executable is pwsh.exe.
Note: You can have both Windows PowerShell and PowerShell versions installed next to each other on the same system.
PowerShell versions and release date
PowerShell has gone a long way since its first release. See the table below for all the PowerShell versions and their release date.
PowerShell version | Release date |
---|---|
PowerShell 7.4 | November 2023 |
PowerShell 7.3 | November 2022 |
PowerShell 7.2 | November 2021 |
PowerShell 7.1 | November 2020 |
PowerShell 7 | March 2020 |
PowerShell 6.2 | March 2019 |
PowerShell 6.1 | September 2018 |
PowerShell 6.0 | January 2018 |
Windows PowerShell 5.1 | August 2016 |
Windows PowerShell 5.0 | February 2015 |
Windows PowerShell 4.0 | October 2013 |
Windows PowerShell 3.0 | October 2012 |
Windows PowerShell 2.0 | July 2009 |
Windows PowerShell 1.0 | November 2006 |
Find PowerShell version
To check which PowerShell version you are running, start Windows PowerShell or PowerShell as administrator and run the below command.
Note: Windows PowerShell and PowerShell are different versions and you need to start the correct PowerShell window and run the command below.
$PSVersionTable.PSVersion
This is how it looks if you run it in Windows PowerShell.
Major Minor Build Revision
----- ----- ----- --------
5 1 20348 1
See the screenshot below.
This is how it looks if you run it in PowerShell.
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 4 0
See the screenshot below.
Install PowerShell 7
There are different methods to install PowerShell on the system. Follow one of the methods below.
Method 1: One-liner
This is the fastest and easiest method to install PowerShell 7.
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
After that, you see the PowerShell 7 setup wizard that you can go through.
Ensure you enable all options.
Since PowerShell 7.2 and higher, Microsoft will automatically update PowerShell 7 in the same release channel if you enable it in the setup wizard. For example, PowerShell 7.2.x to 7.2.y and 7.3.x to 7.3.y.
Enable both options.
Finish the installation.
PowerShell 7 appears in your programs.
Method 2. Download from GitHub
Go to the PowerShell GitHub page and download the PowerShell 7 installer.
Open the PowerShell .msi file and go through the setup wizard, as shown in the above method.
Method 3: WinGet (Windows Package Manager)
Run the below command to download and install PowerShell 7.
Note: It will automatically install PowerShell 7 once downloaded, and you will not see the setup wizard.
winget install --id Microsoft.Powershell
Update PowerShell 7
It’s best to update PowerShell 7 every time a new version is out.
Use the winget upgrade command to update PowerShell 7 to the latest version.
winget upgrade --id Microsoft.PowerShell
The other methods to upgrade PowerShell 7 are to download the installer from GitHub or run the one-liner as shown above, which then you can go through the setup wizard to update PowerShell.
Frequently Asked Questions (FAQ)
How to uninstall Windows PowerShell 5.1 on Windows after installing PowerShell 7?
You don’t. It’s integrated with Windows OS, and you must leave it on your system.
Why does Windows PowerShell ISE show version 5.1 when I have PowerShell 7 installed?
PowerShell ISE loads Windows PowerShell 5.1 and not PowerShell 7.
How can I keep using Windows PowerShell ISE with PowerShell 7?
Switch over to Visual Studio Code. It’s a free, lightweight, open-source, cross-platform code editor.
Will PowerShell 7 load automatically in Visual Studio Code?
PowerShell 7 takes precedence over Windows PowerShell 5.1 and loads by default.
Can I switch between Windows PowerShell 5.1 and PowerShell 7 in Visual Studio Code?
Select a default profile and choose Windows PowerShell 5.1 or PowerShell 7.
How can we know which cmdlets and modules are supported in PowerShell 7?
Microsoft keeps a release history of the modules and cmdlets.
Why doesn’t Microsoft ship PowerShell 7 with Windows?
Microsoft plans to eventually ship PowerShell 7 in Windows as a side-by-side feature with Windows PowerShell 5.1. But they still need to work out some details, and there is no timeline for when that will happen.
Should I use Windows PowerShell 5.1 or PowerShell 7?
You should definitely use PowerShell 7 when you can. But ensure you test all your cmdlets and scripts before transitioning to PowerShell 7.
Read more: How to connect to Microsoft Graph PowerShell »
Conclusion
You learned how to install and update PowerShell 7. Ensure that you use PowerShell 7 when you can because it’s kept up to date by Microsoft and performs much faster than the older versions. If it’s impossible to port some of your commands and scripts to PowerShell 7, then keep using PowerShell 5.1 for those.
Did you like this article? You may also like How to clear Microsoft Teams cache. Don’t forget to follow us and share this article.
You will have to keep in mind that PowerShell 7 might not be effective in your environment (I’m referring to Enterprise environment) like in my case, where PowerShell remoting is DISABLED by InfoSec which means you cannot use CIM but only WMI, the latter is deprecated and not available in PowerShell 7.
I have an extensive collection of scripts and modules that I use in my environment but are written in Windows PowerShell.