Running PowerShell in Version 2
If you have ever wondered how to test your Posh scripts in version 2 of PowerShell when your running Windows 8.1 or an updated Windows 7 (I.e. you have PowerShell 3 or 4). its actually pretty easy.
to open PowerShell in version 2 you simply run:
powershell -version 2
This opens up a new command window. Running Get-Host shows what version you are using:
from here you can simply run your script in the normal fashion.
What’s interesting if that you cant use this method to run PowerShell 3 or 1. Opening a Windows 8.1 client and trying “powershell -version 3” opens a new command window, but Get-Host returns 4. and with “version 1” you open up PowerShell 2 on both a Windows 7 and 8.1 box.