What exactly does PowerShell's -Version parameter do?

By : Joey
Source: Stackoverflow.com
Question!

PowerShell's help (powershell -?) states:

-Version
    Starts the specified version of Windows PowerShell.

However, when starting PowerShell 2 with powershell -Version 1 all things I tried that are only present in v2 and not v1 still work, such as the -split operator or the Get-Random cmdlet.

So what exactly changes when running PowerShell with the -Version parameter if language features and cmdlets that were introduced later still exist and work? This makes testing scripts for PowerShell v1 a bit harder since I don't always remember what has changed.

By : Joey


Answers

I don't think this switch does anything especially since 1.0 and 2.0 can't be installed side-by-side. This switch was put in from the beginning. My guess is that they anticipated being able to run different versions of PowerShell side-by-side. Perhaps that will happen with some future version that installs side-by-side and then this switch will be actually useful.



This video can help you solving your question :)
By: admin