Determine Installed PowerShell Version

As I explained in my previous post “PowerShell ISE” – what version the system is running has a big impact on the script and variables. You will also see in the next post “Automatic Variables” that PowerShell has provided us with a variable for this topic.

$PSVersionTable will give us the PSVersion, PSEdition, PScompatibleVersions, and more.  Example here is from Windows 10:

psversiontable

You only want to know what PSVersion you are currently running on the system that is running the scirpt. We use the . (Single Dot) token that will allow us to access the non-static member of the class or namespace. This is similuar to C#, Java, and other object oriented languages.

$PSVersionTable.PSVersion

Depending on the syntex that is being ran on the computer you can do
$PSVersionTable.PSCompatibleVersions

Note the above commands only show you the current system you are on, but if you want to know another system you have to use the Invoke-Command.

$RemoteComputerName=’TEST’
invoke-command -computername $RemoteComputerName -scriptblock {$PSVersionTable.PSVersion}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s