PowerShell
Andrew Posted on 10:36 am

Update PowerShell Using PowerShell

Need to update to the latest PowerShell version?

I’ll make this your easiest upgrade yet! Remember to test any existing code you have published or run once-and-a-while; then update your VMs and systems that you don’t touch often, that way everything is on the same version.

First, let’s open Visual Studio Code.

Use this awesome MSI tidbit I originally got a while ago from https://thomasmaurer.ch/:

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

When you run this, it will download the MSI installation file and you’ll see a little banner as shown in the image above.

What it really does is:
iex > Invoke-Expression > Runs commands or expressions on the local computer
irm > Invoke-RestMethod > Sends an HTTP or HTTPS request to a RESTful web service

In this case for November 2020, it downloads the following file: https://github.com/PowerShell/PowerShell/releases/download/v7.1.0/PowerShell-7.1.0-win-x64.msi

Isn’t the little AKA download URL way better? I thought so too!

Next, the installer will run automatically and start the install. You can use the standard MSI flags to alter your installation experience here, for example you can add -Quiet and make it a silent install. This is great for installing on remote systems.

Next, we need to update the modules that are currently installed. Try running this:

Update-Module -WhatIf

If you’re happy with what you see, you can run it without the -WhatIf to update all installed modules in one shot.

Update-Module

Once done, that’s all there is to it! Now you are running the latest version of PowerShell with all your modules updated! Simple and repeatable.

I just want to point out the massive amount of improvements and fixes that the PowerShell team includes in every version….thank you!

You can find more information on downloads here: https://aka.ms/Install-PowerShell

PowerShell 7.1 supports a wide variety of operating systems and platforms including:

  • Windows 8.1/10 (including ARM64)
  • Windows Server 2012 R2, 2016, 2019, and Semi-Annual Channel (SAC)
  • Ubuntu 16.04/18.04/20.04 (including ARM64)
  • Ubuntu 19.10 (via Snap package)
  • Debian 9/10
  • CentOS and RHEL 7/8
  • Fedora 30
  • Alpine 3.11+ (including ARM64)
  • macOS 10.13+

There is also community support for:

  • Arch Linux
  • Raspbian Linux
  • Kali Linux

Have fun and I hope you continue to learn new things in many areas!