Updating PowerShell Version on Windows | Windows OS Hub

In this article, we will show how to update your Windows PowerShell version to the latest 5.1 and install ( upgrade to ) PowerShell Core 7.1. In the former article, we told that there are presently two versions of PowerShell : a classical Windows PowerShell ( the latest version is 5.1 and it is no longer developed ) and a new PowerShell Core platform ( version 7.1 is available nowadays ). Despite that the PowerShell adaptation number goes on from 5.1 ( 6.0, 6.1, 7.0, 7.1, etc. ), these are two different platforms. so, we ’ ll express how to update both Windows PowerShell and PowerShell Core .

Upgrading to Windows PowerShell 5.1

PowerShell 4.0 is installed by default on Windows Server 2012 R2 ( Windows 8.1 ). Let ’ s test to update the Windows PowerShell adaptation to 5.1 on Windows Server 2012 R2 .
First of all, check the stream PowerShell version ( the screenshot shows PowerShell 4.0 is installed ) :
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 newer ). 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 free adaptation 378675 means that .NET Framework translation 4.5.1 is installed. so, I have to download and install the latest .NET model 4.8 ( here is the link to the offline installer : hypertext transfer protocol : //go.microsoft.com/fwlink/ ? linkid=2088631 — ndp48-x86-x64-allos-enu.exe ) .
Install the .NET 4.8 ( you will have to reboot 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 ( hypertext transfer protocol : //go.microsoft.com/fwlink/ ? linkid=839516 ) .
Install the Windows Management Framework 5.1 MSU file .
install Windows Management Framework 5.1
After the waiter restart, open the PS comfort and make sure that the PowerShell version has been updated to 5.1 .
update to windows powershell 5.1
.Net Framework 4.5.2 (or newer), then WMF 5.1 (the download links will be different from those for Windows Server 2012 R2). If you have unsupported Windows 7 or Windows Server 2008 R2, you can upgrade the PowerShell translation from 2.0 to 5.1 in the lapp way. First, install ( or newer ), then ( the download links will be different from those for Windows Server 2012 R2 ) .

How to Install or Update to PowerShell Core 7?

note that the latest Windows PowerShell version installed in Windows 10 and Windows Server 2019 is PowerShell 5.1. Microsoft started to develop a cross-platform PowerShell Core version rather. Currently, PowerShell Core 6.0, 6.1, 6.2, 7.0 and 7.1 are available. PowerShell Core is basically a fresh chopine that is installed on the calculator along with Windows PowerShell. It means that you can not upgrade PowerShell 5.1 to PowerShell Core 7.1. PowerShell 7 is installed on a calculator individually from Windows PowerShell 5.1 .
In PowerShell 7.1, the developers added utmost compatibility with Windows PowerShell. sol, you can well run your old PS1 scripts and cmdlets in PowerShell Core .
If you have PowerShell Core 6.0 installed, you can update the PowerShell version on your calculator to the latest PowerShell 7.1 Core ( or you can install PowerShell Core 7.1 together with Windows PowerShell 5.1 ). In this example, we will try to update PowerShell Core in Windows 10 20H2. There are two ways to upgrade :

  • You can download the PowerShell Core MSI installer manually from GitHub;
  • You can download and install (update) it directly from the PowerShell console.

The latest releases of PowerShell Core can be installed on all versions of Windows starting with Windows 7 SP1, Server 2008 R2, and newer .
If you want to install PowerShell Core using the MSI package, go to the project page hypertext transfer protocol : //github.com/PowerShell/PowerShell, find the latest stable secrete. At the time of this spell, this is the March 4, 2021 release of PowerShell v7.1.3. The higher preview Release of PowerShell v7.2.0 is besides available, but you ’ d better wait for a more stable version. Expand the Assets tilt and find a software for your Windows interpretation ( PowerShell-7.1.3-win-x64.msi or PowerShell-7.1.3-win-x86.msi ) .
github - get latest powershell core release

Download the MSI file and install it .
install powershell core on windows
To install PowerShell Core from an MSI package using SCCM/MDT/scripts in quieten mood, you can use a command with the following parameters : msiexec.exe /package PowerShell-7.1.0-win-x86.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1
You can update the PowerShell right from the PS command line interface .
Let ’ s update ( install ) the latest PowerShell Core translation using the command :
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
This command downloads the PowerShell 7.1 MSI distribution file from GitHub and then starts the facility via the MSI installer .

  • -Destination – change the default PowerShell Core installation folder
  • -Preview – install the latest Preview PowerShell version
  • -Quiet – a quiet installation mode
  • -AddToPath – adds a path to the PowerShell Core installation directory to the environment variables

You can besides use other initiation parameters :

upgrade powershell core 7.1 from command line
After the facility is finished, the PowerShell Core ( pwsh.exe ) window appears. Check the PowerShell version here to make sure it is classy 7.1.3 .
poweshell core 7.1 on windows 10 - pwsh.exe
If you have the WinGet package director installed, you can install or update your PowerShell version to the latest dominate :
winget install --id=Microsoft.PowerShell -e
Or, you can install a specific adaptation of PowerShell Core :
winget install --id=Microsoft.PowerShell -v "7.1.2" -e
If you have Chocolatey package coach installed, use the commands :
choco install powershell -y
choco upgrade powershell -y

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

Pay attention to the directories of different PowerShell versions :

  • 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 calculator, the $env:ProgramFiles\PowerShell\6 directory is mechanically removed when you install PowerShell 7.1 .
note that the name of the PowerShell feasible 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.1 installed on your calculator .
two powershell verions on window 10
In order to find out the adaptation and build of PowerShell 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 translation of a file on a remote control calculator :
Invoke-Command -Computername computer1 -Scriptblock {(Get-Command 'C:\Program Files\PowerShell\7\pwsh.exe').Version}
Windows PowerShell provides a especial backward compatibility mood that allows you to run an older version of PowerShell even if you have newer versions installed. You can start PowerShell of a specific translation ( for example 4.0 ) with the pursue command :
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 4

Installing PowerShell Core via Microsoft Store

On Windows 10, you can install or update PowerShell via the Microsoft Store. You can manually find the PowerShell app in the storehouse or use this link. The advantage of this initiation method acting is that the Store app will track the install interpretation of PowerShell and automatically install app updates as they become available .
But there are besides disadvantages to the fact that such a PowerShell example will run in a sandbox .
install powershell on windows via microsoft store
Add-AppxPackage cmdlet (or as described in the article “ You can download the APPX /MSIX application file and install it using thecmdlet ( or ampere described in the article “ Repairing Microsoft Store ” ) .

Deploying PowerShell Core with Group Policy

In the Active Directory world, you can centrally deploy and update PowerShell Core using Group Policy. Use the GPO ’ mho features to install MSI packages .

  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 You can use the GPO WMI filters to more accurately target your policy to domain devices .
  4. To update the software installation Group Policy settings, you need to restart the computers. The new version of PowerShell will be installed on all computers at startup.

Updating PowerShell Remotely

You can use one of the follow methods to update PowerShell on remote control computers via the command prompt .
The inaugural method allows you to remotely update PowerShell on the calculator using the MSI installer in the shared network folder :
Invoke-Command -ComputerName mun-srv01 -ScriptBlock {Start-Process msiexec.exe -ArgumentList '/package "\\mun-fs01\install\PowerShell-7.1.3-win-x64.msi" /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1' -Wait}
The follow script will select all active Windows 10 computers from the Active Directory domain and start download 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"}

Be careful when using the 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.1 end point, you need to use the command :
Enter-PSSession -ComputerName dc01 -ConfigurationName "powershell.7.1.3"

otherwise, you will connect to the PowerShell Remoting 5.1 end point .

source : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also


Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.