How to check the PowerShell version installed in local and remote systems?

To check the PowerShell version installed in your system, you can use either $PSVersionTable or $host command.

  • Check if $host command available in remote servers.

Open the PowerShell console in the system and run the command $PSVersionTable.



PS C:\WINDOWS\system32> $PSVersionTable
Name                             Value
----                             -----
PSVersion                        5.1.18362.628
PSEdition                        Desktop
PSCompatibleVersions             {1.0, 2.0, 3.0, 4.0...}
BuildVersion                     10.0.18362.628
CLRVersion                       4.0.30319.42000
WSManStackVersion                3.0
PSRemotingProtocolVersion        2.3

So here, we have an output of the $PSVersionTable. You can see the output property $PSVersion, which indicates the version information of the PowerShell.



Major    Minor    Build    Revision
-----    -----    -----    --------
5       1         18362    628

In the Major property, it indicates the PowerShell version is 5 and Build is 18362.

Similarly, you can get the above output with the $Host command in PowerShell.

PS C:\WINDOWS\system32> $Host
Name :                       ConsoleHost
Version                      : 5.1.18362.628
InstanceId                   : f6d2bf19-db26-403b-9749-afede37ea56f
UI                           : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture               :en-IN
CurrentUICulture             : en-US
PrivateData                  : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled              : True
IsRunspacePushed             : False
Runspace                     : System.Management.Automation.Runspaces.LocalRunspace

You can get the PowerShell version from version property.



PS C:\WINDOWS\system32> $Host.Version
Major    Minor    Build    Revision
 -----   -----    -----    --------
 5       1        18362    628

To get the output on the remote computer, you need to use Invoke-Command or PSRemote session command as the $PSverionTable and $Host doesn’t support the − ComputerName Parameter.

Invoke-Command -ComputerName Test-PC -ScriptBlock{$PSVersionTable.PSVersion}

If you have multiple computers and if you need the Hostname and the PS version against the hostname then you can use the Pipeline or the PSCustomObject command.


Invoke-Command -ComputerName Test-PC,DC1 -ScriptBlock{$PSVersionTable.PSVersion} | Select PSComputerName, @{N="PS Version";E={$_.Major}}

If you have a list of servers then you can add all the servers into the text file and run the above command.

For example, We have servers list stored in D:\Temp\Servers.txt and we need to get the PS version on them.

Invoke-Command -ComputerName (Get-Content D:\Temp\Servers.txt) -
ScriptBlock{$PSVersionTable.PSVersion} | Select PSComputerName, @{N="PS Version";E={$_.Major}}