Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / PowerShell / Updating PowerShell Version on Windows

April 12, 2023 PowerShellWindows 10Windows 11Windows Server 2012 R2Windows Server 2019

Updating PowerShell Version on Windows

This article describes how to update Windows PowerShell to the latest version 5.1 and how to install (upgrade) PowerShell Core 7.3. There are currently two branches of PowerShell:

  • The classic Windows PowerShell (the maximum version is 5.1, which is no longer being developed.);
  • The new PowerShell Core platform (version 7.3 is available now).

Although the PowerShell version numbering continues from 5.1 (6.0, 6.1, 7.0, 7.1, and so on), they are two different platforms. Therefore, updating Windows PowerShell and PowerShell Core will be covered separately.

PowerShell Core 7.x is the version that is most compatible with classic Windows PowerShell. This means that you can easily run your old PS1 script files and cmdlets in PowerShell Core.  

Contents:
  • Upgrading to Windows PowerShell 5.1
  • How to Install or Update PowerShell Core 7?
  • Installing/Updating PowerShell Core on Remote Computers
  • Updating PowerShell via Windows Update or WSUS

Upgrading to Windows PowerShell 5.1

Windows PowerShell 5.1 is already installed by default in all versions, starting with Windows 10 and Windows Server 2016.

You must manually upgrade to PowerShell 5.1 for earlier versions (Windows 7/8.1 and Windows 2008 R2/2012). For example, Windows Server 2012 R2 (Windows 8.1) has PowerShell 4.0 installed.

Let’s try upgrading the Windows PowerShell version to 5.1 in Windows Server 2012 R2.

First, check the current PowerShell version (the screenshot shows that it’s PowerShell 4.0):

$PSVersionTable.PSVersion

PSVersionTable.PSVersion check powershell version

To upgrade your PowerShell version to 5.1, install the Windows Management Framework 5.1, which requires the .NET Framework 4.5.2 (or later). Make sure that .NET 4.5.2 or higher is installed using this command:

(Get-ItemProperty ‘HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full’ -Name Release).Release

get .net framework version on windows

In my case, the release version 378675 means that the .NET Framework version 4.5.1 is installed. So, I have to download and install the latest .NET Framework 4.8 (here is the link to the offline installer: https://go.microsoft.com/fwlink/?linkid=2088631 — ndp48-x86-x64-allos-enu.exe).

Install the .NET 4.8 package (you will need to restart your computer):

installing net framework 4.8 on windows server 2012 r2

If you install WMF 5.1 without .NET 4.5.2, some PowerShell features will not be available.

Download WMF 5.1 for Windows Server 2012 R2 — Win8.1AndW2K12R2-KB3191564-x64.msu (https://go.microsoft.com/fwlink/?linkid=839516).

Install the Windows Management Framework 5.1 from the MSU file.

install Windows Management Framework 5.1

After you restart the server, open the powershell.exe console and make sure that the PowerShell version has been updated to 5.1.

update to windows powershell 5.1

If you have unsupported Windows 7 or Windows Server 2008 R2, you can upgrade the PowerShell version from 2.0 to 5.1 in the same way. First, install .Net Framework 4.5.2 (or newer), then WMF 5.1 (the download links will be different from those for Windows Server 2012 R2).

How to Install or Update PowerShell Core 7?

PowerShell Core is cross-platform and under active development (unlike Windows PowerShell 5.1). Actually, PowerShell Core is a new platform installed on the operating system alongside the classic Windows PowerShell. This means that you cannot upgrade from PowerShell 5.1 to PowerShell Core 7.3. PowerShell 7.x is installed on your computer separately from Windows PowerShell 5.1 (side-by-side).

PowerShell Core 6.x and 7.x are available at this time. It is recommended that you always install the latest version of PowerShell (currently 7.3) unless you need special compatibility with legacy scripts.

There are several ways to upgrade (install) the PowerShell Core version on Windows 10 and 11:

  • Use the PowerShell Core MSI installer, which is available to download from GitHub;
  • Using the built-in Windows 10/11 package manager WinGet;
  • Using the Microsoft Store.

Next, using the example of updating PowerShell Core to 7.3 on Windows 10 22H2, we will look at all of these methods.

Upgrading the PowerShell Core Using MSI installation

If you want to install PowerShell Core using the MSI package, go to the project page https://github.com/PowerShell/PowerShell and download the installation package for your OS version. At the time of writing, the most recent release of PowerShell is v7.3.3, dated 24 February 2023 (for example, PowerShell-7.3.3-win-x64.msi or PowerShell-7.3.3-win-x86.msi). Use only stable or LTS releases for a production environment.

download powershell core msi installer from github

Download the MSI file and install it.

The following installation options are available:

  • Add PowerShell to Path Environment Variable
  • Register Windows Event Logging Manifest (a separate Event Viewer log is created for PowerShell events. %SystemRoot%\System32\Winevt\Logs\PowerShellCore%4Operational.evtx )
  • Enable PowerShell Remoting (enables and configures WinRM for PowerShell Remoting)
  • Add ‘Open here’ context menu to Explorer
  • Add ‘Run with PowerShell 7’ context menu for PowerShell files

install powershell core on windows

Next, you can enable automatic updates of the PowerShell Core through Windows Update/WSUS (see below).

enable powershell core update via microsoft update

To install PowerShell Core from an MSI package using SCCM/MDT/scripts in quiet mode, you can use a command with the following parameters:

  • ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL
  • ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL
  • ENABLE_PSREMOTING
  • REGISTER_MANIFEST
  • ADD_PATH
  • DISABLE_TELEMETRY
  • USE_MU – use the Microsoft Update to get PSCore updates
  • ENABLE_MU – allow the PowerShell Core to be updated through Windows Update

For example, the command for a silent installation might look something like this:

msiexec.exe /package PowerShell-7.3.3-win-x64.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1 ADD_PATH=1 ENABLE_MU=1 ADD_PATH=1

You can upgrade PowerShell directly from the console. To install or upgrade to the latest version of PowerShell Core, run the following command:

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

This command downloads the PowerShell 7.3 MSI file from GitHub and then starts the installation via the MSI installer.

upgrade powershell core 7.1 from command line

When the installation is complete, the PowerShell Core (pwsh.exe) window appears. Check the PowerShell version to ensure that it is updated to PoSh 7.3.3.

powershell core updated to 7.3

Using WinGet Package Manager to Install or Update PowerShell Core

If you have the WinGet package manager installed, you can install or update your PowerShell version to the latest command:

winget install --id Microsoft.Powershell --source winget

Or, you can install a specific version of PowerShell Core:

winget install --id=Microsoft.PowerShell -v "7.1.2" -e

If you have the Chocolatey package manager installed, use the commands (for 5.1):

choco install powershell -y
choco upgrade powershell -y

or for PowerShell 7.x:
choco install pwsh -y
choco install pwsh -y

Note the default directories for different versions of PowerShell:

  • Windows PowerShell 5.1: $env:WINDIR\System32\WindowsPowerShell\v1.0
  • PowerShell Core 6.x: $env:ProgramFiles\PowerShell\6
  • PowerShell Core 7.x: $env:ProgramFiles\PowerShell\7

If PowerShell 6.x was installed on your computer, the $env:ProgramFiles\PowerShell\6directory is automatically removed when you install PowerShell 7.3.

Note that the name of the PowerShell executable file has changed. In PowerShell Core, it is c:\Program Files\PowerShell\7\pwsh.exe. It has its own icon in the Start menu.

  • To run .NET Framework-based Windows PowerShell, the powershell.exe command is used
  • To run .NET Core-based PowerShell Core, use the pwsh.exe

pwsh.exe - powershell core executable

This means that you have both Windows PowerShell 5.1 and PowerShell Core 7.3 installed on your computer.

two powershell version on windows 10

To find the version and build of PowerShell that is installed on your device, you can check the version of the pwsh.exe file:

(Get-Command 'C:\Program Files\PowerShell\7\pwsh.exe').Version

get pwsh.exe file version

This is how you can check the version of a file on a remote computer:

Invoke-Command -Computername computer1 -Scriptblock {(Get-Command 'C:\Program Files\PowerShell\7\pwsh.exe').Version}

Windows PowerShell provides a special backward compatibility mode that allows you to run an older version of PowerShell even if you have newer versions installed. You can use the following command to run a specific version of PowerShell example, 4.0):

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 4

Install PowerShell Core on Windows 10 and 11 via Microsoft Store

On Windows 10 and 11, you can install or update PowerShell through the Microsoft Store. You can manually find the PowerShell app in the Store or use this link.

You can also use WinGet to install the Store version of PowerShell:

winget search powershell --source msstore
winget install --id 9MZ1SNWT0N5D

The advantage of installing PowerShell Core from the Microsoft Store is that the App Store automatically checks your installed version of PowerShell and automatically installs updates as they become available.

To verify that you have installed the Store version of PowerShell Core, use the command:

Get-AppPackage Microsoft.PowerShell

The Microsoft.PowerShell_7.3.3.0_x64__8wekyb3d8bbwe package is installed in this example.

appx-package of powershell core from microsoft store

However, there are also drawbacks to the fact that such an instance of PowerShell will be running in a sandbox environment.

install powershell on windows via microsoft store

You can download the APPX/MSIX application file and install it using the Add-AppxPackage cmdlet (or as described in the article “Repairing Microsoft Store”).

Installing/Updating PowerShell Core on Remote Computers

Consider two scenarios for installing or updating the PowerShell Core on multiple remote computers.

Deploying PowerShell Core with Group Policy

You can use Group Policy to centrally deploy and update PowerShell Core in an Active Directory domain. Use the features of the GPO to deploy MSI packages to domain computers.

  1. Download the PowerShell MSI installation file and copy it to the SYSVOL directory on the domain controller;
  2. Open the Domain Group Policy Management Console (gpmc.msc), create a new GPO and link it to the OU with computers and servers;
  3. Go to the GPO section Computer Configuration -> Software Settings, create a new package, and specify the path to the PowerShell MSI installation file in the SYSVOL folder in the domain (use the UNC path); updating powershell on domain computers using gpo
    To more accurately target your policy to domain devices, you can use the GPO WMI filters.
  4. To update the Group Policy settings for the software installation, you must restart the computers. The new version of PowerShell will be installed on all computers at startup.

How to Update PowerShell on a Remote Computer from the Command Prompt?

You can use the command line prompt to update PowerShell on a remote computer.

  • The first method uses an MSI installer in a shared network folder to remotely update PowerShell on a computer:Invoke-Command -ComputerName mun-srv01 -ScriptBlock {Start-Process msiexec.exe -ArgumentList '/package "\\mun-fs01\install\PowerShell-7.3.3-win-x64.msi" /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1' -Wait}
  • The following script selects all enabled computers running Windows 10 from the Active Directory domain and starts downloading and installing PowerShell Core on each of them:
    $ADComputers = Get-ADComputer -Filter 'operatingsystem -like "*Windows 10*" -and enabled -eq "true"'
    ForEach ($computer in $ADcomputers) {
    Invoke-Command -ComputerName $computer {iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI -Quiet"}
    }
    You must have the Active Directory PowerShell module installed on the computer to use the GetADComputer cmdlet.
Take care when using PowerShell Remoting commands when connecting to remote computers (with the  Enter-PSSession and Invoke-Command cmdlets). If you need to connect to a PowerShell 7 endpoint, you must use the command:

Enter-PSSession -ComputerName dc01 -ConfigurationName "powershell.7"

Otherwise, you will connect to the PowerShell Remoting 5.1 endpoint.

The most common way to update the PowerShell Core on Linux distros is to use the native package manager.

Updating PowerShell via Windows Update or WSUS

Prior to PowerShell Core 7.2, pwsh.exe was not automatically updated. There was only a notification in the console after the release of a new version:

A new PowerShell stable release is available. Upgrade now, or check out the release page at: https://aka.ms/PowerShell-Release?tag=v7.1.3

console notification: A new PowerShell stable release is available

Starting with version 7.2, PowerShell Core supports automatic updates through Windows Update (Microsoft Update, Windows Update for Business, internal WSUS server, or SCCM). To do this, you must enable the appropriate options during the installation of the MSI package.

  • The first allows PowerShell to update automatically using any available channel (enables the registry parameter UseMU =1 in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShellCore key) UseMU reg key: enable autoupdate of powershell core
  • The second checkbox will allow you to receive updates for all of Microsoft’s software, not just Windows. If this option is disabled, you will not receive PowerShell updates from Microsoft Update, but you can receive them from your WSUS/SCCM (the registry parameter  registeredwithAU=1 under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\7971F918-A847-4430-9279-4A52D1EFE18D)registeredwithAU registry

Check that the Receive updates for other Microsoft products when you update Windows option is now enabled under Settings -> Update and Security -> Windows Update -> Advanced options.

enable the option: receive updates for other microsoft products via windows update

An administrator can configure update installation options through Group Policy settings.

Now, when you click the Check for Updates button or run an update scan through the PSWindowsUpdate module, you will also receive updates for PowerShell Core.

windows check for powershell updates

10 comments
8
Facebook Twitter Google + Pinterest
previous post
How to Delete OEM Recovery Partition in Windows?
next post
Turn Linux Computer into Wi-Fi Access Point (Hotspot)

Related Reading

Configuring Event Viewer Log Size on Windows

May 24, 2023

How to Detect Who Changed the File/Folder NTFS...

May 24, 2023

Enable Single Sign-On (SSO) Authentication on RDS Windows...

May 23, 2023

Allow Non-admin Users RDP Access to Windows Server

May 22, 2023

How to Create, Change, and Remove Local Users...

May 17, 2023

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Configuring Event Viewer Log Size on Windows

    May 24, 2023
  • How to Detect Who Changed the File/Folder NTFS Permissions on Windows?

    May 24, 2023
  • Enable Single Sign-On (SSO) Authentication on RDS Windows Server

    May 23, 2023
  • Allow Non-admin Users RDP Access to Windows Server

    May 22, 2023
  • How to Create, Change, and Remove Local Users or Groups with PowerShell?

    May 17, 2023
  • Fix: BSOD Error 0x0000007B (INACCESSABLE_BOOT_DEVICE) on Windows

    May 16, 2023
  • View Success and Failed Local Logon Attempts on Windows

    May 2, 2023
  • Fix: “Something Went Wrong” Error When Installing Teams

    May 2, 2023
  • Querying Windows Event Logs with PowerShell

    May 2, 2023
  • Configure Windows LAPS (Local Administrator Passwords Solution) in AD

    April 25, 2023

Follow us

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Configuring Port Forwarding in Windows
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Delete Old User Profiles in Windows?
  • Adding Drivers into VMWare ESXi Installation Image
  • Configuring SFTP (SSH FTP) Server on Windows
  • How to Find the Source of Account Lockouts in Active Directory?
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top