PSH V1 or V2?

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.

 (get-command $pshome\powershell.exe).fileversioninfo.productversion

 will report for V1 and for V2

Comments (1)

  1. Is there a reason to not use $PSVersionTable.PSVersion to get the engine's version?

Skip to main content