Introduction
By default, PowerShell 7 is not included with the operating system. In this post, we are looking at different ways how you can install it.
Using Winget on Windows 10 / Windows 11
On Windows 10 and Windows 11, you can use the Winget utility. Winget is Windows Package Manager, which is already built-in in the operating system. Winget is a command-line tool, and it makes it much easier to install the software.
On your Windows client machine, run the following commands:
- Winget search Microsoft.PowerShell
- Winget install Microsoft.PowerShell or Winget install PowerShell
You should now have PowerShell 7.X on your computer after running these commands. From the start menu, open PowerShell 7.X and print out the $PSVersionTable variable.
As you see, installing software through Winget command-line utility is easy.
Microsoft Store
The second option is to install it through the Microsoft App Store. Open Microsoft Store from your start menu and search for PowerShell.
Click Get and you are ready to go 😊
Install-PowerShell.PS1 PowerShell Script
Winget and Microsoft Store aren’t available on Windows Server operating systems. In that case, we can download the MSI manually and then use PowerShell to install it locally or remotely, but there is another option for us.
I discovered that Microsoft has a really interesting script for installing PowerShell 7.X and has different parameters you can specify.
Install-Powershell.PS1 script parameters
- Destination
- Daily
- DoNotOverwrite
- AddToPath
- UseMSI
- Quiet
- AddExplorerContextMenu
- EnablePSRemoting
- Preview
You can view the script here – https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1
You can download and execute the script using a single command:
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -UseMSI -Quiet"
Invoke-RestMethod downloads the script, and Invoke-Expression allows you to execute directly. This script is able to download the latest version of PowerShell 7.X.
It reads the following variable data from this JSON file
Execute the command as an administrator and you should see the following output.
Install-Powershell.ps1 script is not only for Windows machines but also for Linux and macOS.
Conclusion
PowerShell 7 is a significant upgrade over Windows PowerShell, offering a host of new features and improvements. Whether you’re a seasoned PowerShell user or just getting started, this guide should help you install PowerShell 7 on your Windows machine with ease.