My lab has some machines that are only running PSH v1 (for reasons outside the scope of this article.) The easiest way is to try to run something that exists on V2, such as “import-module”. However, the progamatic way is to get the ProductVersion property of the FileVersionInfo property of the $PSHOME\powershell.exe filesystem object.
Except that Get-item under V1 doesn’t expose the FileVersionInfo property. >_< And to matters even worse, even new versions of PS will install in v1.0 to keep backward compatibility for some reason.
will report 6.0.xyz for V1 and 6.1.xyz for V2