01 June,2017 by Tom Collins
Checking the Powershell version is a requirement for an upgrade cycle. How can I programatically extract the Powershell version and create a report . This would allow me to include a check before I execute some code?
Answer: The Powershell version can be extracted from the $PSVersionTable variable. The $PSVersionTable contains other information which I’ve included in this output.
PS > $PSVersionTable Name Value ---- ----- CLRVersion 2.0.50727.5485 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 get only the PSVersion use $PSVersionTable.PSVersion
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |