How Do I install PowerShell 7?

Featured image

Why?

You may be surprised to learn that Microsoft doesn’t ship the newest version of PowerShell 7 with Windows 10, 11 or Windows Server. Instead the default version shipped is Windows PowerShell v5 which ceased development in 2016. PowerShell Core v6 was also released in 2016 and it’s successor is PowerShell 7 (the Windows and Core in the name were dropped when PowerShell 7 was released in 2020).

In this post, I’ll show you how to install PowerShell 7 alongside PowerShell 5 to make sure you have access to all the new features that PowerShell 7 has to offer, now and in the future.

Check the version shipped with Windows

To see for youself that version 5 is indeed installed on Windows 10, 11 or Windows Server, open up PowerShell and use the psversiontable object to see the version:

$psversiontable.psversion

Download PowerShell 7

Although we can go to the Micosoft GitHub repo to download the latest msi, I’ll show you how to download it using a .net object in PowerShell which can be used in scripts and automations:

Create a .net webclient

$w = New-Object System.Net.WebClient

Download the msi (check the latest version of PowerShell at Micosoft GitHub repo). Note: I named the downloaded file p7.msi in the second argument.

$w.DownloadFile("https://github.com/PowerShell/PowerShell/releases/download/v7.2.4/PowerShell-7.2.4-win-x64.msi", "p7.msi")

Verify the file is downloaded

ls

Install PowerShell 7

The msi is a standard Windows GUI wizard and the install involves some important options, but first let’s run the msi:

.\p7.msi

PowerShell 7 Welcome Wizard

Note: Although this is a GUI wizard it will run in Windows Server Core as well.

I recommend checking all the Optional Actions to enable PowerShell remoting and to add the additional shortcuts:

PowerShell 7 Optional Actions

Lastly I recommend leaving the update options checked to ensure PowerShell updates are installed:

PowerShell Updates

Once the install completes, you should exit out of the PowerShell session if you still have it running before trying to run PowerShell 7. For Windows Server Core I suggest you log out and log back in.

Using PowerShell 7

First things first, I pin both versions of PowerShell to the taskbar by right clicking each one and choosing the pin to taskbar option. This allows me to get to the different versions of PowerShell quickly; Windows PowerShell 5 has a lighter blue icon and PowerShell 7 has a darker blue icon.

To see how to use the two different versions, open a command prompt by typing cmd in Windows search:

cmd

To use PowerShell version 5 type:

powershell

Verify that you are using version 5:

$psversiontable.psversion

End your Windows PowerShell 5 session:

exit

To use PowerShell 7 type:

pwsh

The welcome message will display the version is indeed PowerShell 7.

A quick note on aliases:

Let’s remove the msi file we downloaded and check it’s gone:

rm p7.msi

ls

You will see the msi file has been deleted but you may be wondering why linux command line commands like ls and rm are working in PowerShell. It’s because PowerShell uses aliases to allow admins from other systems to use commands familiar to them. You can see the real PowerShell commands that are running in the background by using the Get-Alias command:

Get-Alias ls

Get-Alias rm

For ls, the Get-ChildItem PowerShell command is running and for rm the Remove-Item command is running, pretty cool huh?

Where to now?

PowerShell 7 is a cross platform program (can run on Windows, Mac and Linux), is the replacement to Windows PowerShell 5 and PowerShell Core 6 and a powerful automation and scripting program. In the right hands, it can replace many old ways of doing things like using group policies for everything, centrallised configuration management, vb scripts and application packaging techniques.

Whether you’re just starting to learn about PowerShell or an experienced user, stick around because I’ll be sharing many tips, tricks and PowerShell solutions in the future.

The future of IT in my opinion is knowing how and when to automate things that IT professionals used to do manually and PowerShell is a extremely useful tool to have in the toolbox. With that in mind, I’ll leave you with a recommendation I included in a post implementation review for an IT infastructure project I recently delivered successfully:

automate the boring stuff so that staff can concentrate on providing value and service.

If you want to learn more about PowerShell, check out this popular book that guides you through learning PowerShell by spending an hour a day for a month.