安装v4后,您能模仿PowerShell v3吗?

Guy*_*mas 4 powershell powershell-3.0 powershell-4.0

我想模仿PowerShell 3.0

在PowerShell v3或v4中,您可以使用以下命令模拟v2:

%windir%\system32\WindowsPowerShell\v1.0\PowerShell.exe -version 2
Run Code Online (Sandbox Code Playgroud)

$ Host揭示:版本:2.0

但是,在PowerShell 4中

%windir%\system32\WindowsPowerShell\v1.0\PowerShell.exe -version 3
Run Code Online (Sandbox Code Playgroud)

$ Host now报告:版本:4.0(我希望3:0)

问题:有没有办法从4.0模拟PowerShell 3.0?

Jas*_*irk 6

不,这是不可能的.V4向后兼容V3,因此任何针对V3编写的脚本都可以与V4一起使用.

如果要编写支持V3和V4的脚本,最好使用安装了V3的计算机/ VM,以确保不依赖于V4功能.