问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/1992196/what-exactly-does-powershells-version-parameter-do