I use Windows 7 (64 bit) with Powershell V3 installed on it. Most of our users are still on PowerShell v2, Sometime when I am writing scripts for them i use some PowerShell v3 cmdlets accidently.
Normally I write the initially version of all scripts on PowerShell console and I do test my all script in the console only.
So I thought there must be a way to run PowerShell.exe with Version 2 only.
I found the solution and i thought I should share it with You.
It’s simple, Just run “Powershell.exe –Version 2” and this will open a PowerShell console with V2 cmdlets only.
Let’s test it.
When i run $PSVersionTable in my PowerShell console, you can see that my PSversion is 3.0.
Now lets run “Powershell.exe –Version 2” .
and new PowerShell console will open and let’s check it’s $PSVersionTable.
You can see that this PowerShell version of this console is 2.0.
Now let’s check one more thing. Let’s see if version 2 is having Version 3.0 cmdlets or not (just to make our self bit more confident).
Let’s search for all cmdlets those has the word Update. The Version 3 has a new cmdlet named “Update-Help”.
“Get-Command *update* -CommandType cmdlet”
and then run the same command on v2 PowerShell console.
You can check that , Update-Help cmdlet is not available on V2 console 🙂
Now i can use it and create a V2 script more confidentiality, without worrying of using v3 cmdlets accidentally. . 🙂
Note: I tested this on Windows 7 (64 bit) with PowerShell v3 installed.
Thanks for reading and your time,.