What exactly does PowerShell's -Version parameter do?

好久不见. 提交于 2019-12-11 01:43:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!