Can you mimic PowerShell v3 once you have installed v4?

你。 提交于 2019-12-01 20:43:09

问题


I want to emulate PowerShell 3.0

From PowerShell v3 or v4 you can emulate v2 with this command:

%windir%\system32\WindowsPowerShell\v1.0\PowerShell.exe -version 2

$Host reveals: Version: 2.0

However, in PowerShell 4

%windir%\system32\WindowsPowerShell\v1.0\PowerShell.exe -version 3

$Host now reports: Version: 4.0 (I was hoping for 3:0)

Question: Is there any way of emulating PowerShell 3.0 from 4.0?


回答1:


No, it's not possible. V4 is backwards compatible with V3, so any script written targeting V3 will work fine with V4.

If you want to write scripts that support both V3 and V4, it's best to use a machine/VM with V3 installed to make sure you don't rely on V4 features.



来源:https://stackoverflow.com/questions/21554993/can-you-mimic-powershell-v3-once-you-have-installed-v4

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