Table of Contents
Method 1: Upgrade PowerShell Manually
You can update to PowerShell 5.1 on Windows 7, and in fact it’s recommended to do so to add suspicious-script block-logging that is not in the PowerShell shipped on Windows 7.
$PSversiontable
PS C:\Users\bonguides> $PSversiontable
Name Value
---- -----
CLRVersion 2.0.50727.8964
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
To install PowerShell 5.1 on Windows 7, there are a few mandatory prerequisites:
1. Install Microsoft .NET Framework 4.5 on Windows 7.
2. Install Windows Management Framework 4.0.
3. With the first two steps done, you can install Windows Management Framework 5.1. Once this is in place, you can use the abilities of PowerShell 5 on Windows 7 and turn on the enhanced logging that 5 provides.
PS C:\Users\bonguides> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Method 2: Upgrade using scipts
1. Install Microsoft .NET Framework 4.5 on Windows 7.
2. Install Windows Management Framework 4.0 then restart your computer. If the update was installed, you can skip this step.
Import-Module BitsTransfer
$arch=(Get-WmiObject -Class Win32_operatingsystem).Osarchitecture
If ($arch -eq "32-bit") {
$kbUrl32 = "https://filedn.com/lOX1R8Sv7vhpEG9Q77kMbn0/2023/Windows6.1-KB2819745-x86-MultiPkg.msu"
$kb32 = "Windows6.1-KB2819745-x86-MultiPkg.msu"
Start-BitsTransfer -source $kbUrl32
wusa $kb32 /log:install.log
}
Else {
$kbUrl64 = "https://filedn.com/lOX1R8Sv7vhpEG9Q77kMbn0/2023/Windows6.1-KB2819745-x64-MultiPkg.msu"
$kb64 = "Windows6.1-KB2819745-x64-MultiPkg.msu"
Start-BitsTransfer -source $kbUrl64
wusa $kb64 /log:install.log
}
After the computer restarted, this time if you check the version of Powershell. It should be 4.0 like below.
PS C:\Users\bonben365> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.16406
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
3. With the first two steps done, you can install Windows Management Framework 5.1. Once this is in place, you can use the abilities of PowerShell 5 on Windows 7 and turn on the enhanced logging that 5 provides.
Import-Module BitsTransfer
$arch=(Get-WmiObject -Class Win32_operatingsystem).Osarchitecture
If ($arch -eq "32-bit") {
$kbUrl32 = "https://filedn.com/lOX1R8Sv7vhpEG9Q77kMbn0/2023/Win7-KB3191566-x86.msu"
$kb32 = "Win7-KB3191566-x86.msu"
Start-BitsTransfer -source $kbUrl32
wusa $kb32 /log:install.log
}
Else {
$kbUrl64 = "https://filedn.com/lOX1R8Sv7vhpEG9Q77kMbn0/2023/Win7AndW2K8R2-KB3191566-x64.msu"
$kb64 = "Win7AndW2K8R2-KB3191566-x64.msu"
Start-BitsTransfer -source $kbUrl64
wusa $kb64 /log:install.log
}