Powershell provides different features according to its version. Here knowing the version of the Powershell become a necessity. There are different methods to get version of Powershell from easy to hard.
Using PSVersionTable Environment Variable
Simplest and reliable solution is using environment variable. PSVersionTable variable provides PSVersion key for the version.
- Major column shows the real version.
- If there is no result it is safe to assume version 1