- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
$PSVersionTable
Output
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 SerializationVersion 1.1.0.1
So here, we have an output of the $PSVersionTable. You can see the output property $PSVersion, which indicates the version information of the PowerShell.
$PSVersionTable.PSVersion
Output
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.
$Host.Version
Output
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.
Example
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}}
- Related Articles
- How to check if remote ports are open using PowerShell?
- How to install the specific version of the PowerShell module version?
- How to change the TLS version in PowerShell?
- How to get installed windows update using PowerShell?
- How to get the installed Azure VM extension using PowerShell?
- How to Find out Linux Version currently Installed on your Machine?
- How to install the latest PowerShell module version?
- How to copy files/folders to the remote location in the PowerShell?
- How to restart a remote system using PowerShell?
- How to test remote computer connectivity using PowerShell?
- How to find the device driver version using PowerShell?
- How to check the OS version in Swift?
- How To Check MySQL Version
- How to change the local disk name using PowerShell?
- How do I know which MongoDB version is installed using the Command Line?
