Detecting what version of PowerShell is currently installed

During automation there will be a time where are specific powershell version will be required. In order to properly detect this you must use the following object: “$PSVersionTable.PSVersion” DO NOT use $Host.Version and (Get-Host).Version as they show the host version not the engine version. Here is a quick example of how to use this in practice.

PSVersion has a few properties in it, we are using Major to just return the number and then use that to compare to the lowest version that is compatible. Hope this helps!

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.