powershell.exe - 版本 2.0 正在冻结 ISE 和控制台(版本 4)

powershell.exe -version 2.0 is Freezing ISE & Console (Version 4)

我正在尝试在 4.0 版中模拟 powershell 2.0 版

以下只是冻结应用程序:

PS H:\> powershell.exe -version 2.0

我确实收到了以下文本,但是控制台继续 运行,我无法执行进一步的脚本。

Windows PowerShell 
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

据我所知,ISE 中的命令 window 并不是真正的控制台 window。它只是假装它是。实际上,它是 运行 在后台执行命令并将输出复制到命令 window。

请注意,当您尝试 运行 cmd.exe 时,您会得到:

Cannot start "cmd". Interactive console applications are not supported. 
To run the application, use the Start-Process cmdlet or use "Start PowerShell.exe" from the File menu.
To view/modify the list of blocked console applications, use $psUnsupportedConsoleApplications, or consult online help.
At line:0 char:0

同样,运行ning powershell.exe 单独给了我这个:

Cannot start "powershell". Interactive console applications are not supported. 
To run the application, use the Start-Process cmdlet or use "Start PowerShell.exe" from the File menu.
To view/modify the list of blocked console applications, use $psUnsupportedConsoleApplications, or consult online help.
At line:0 char:0

我不确定 powershell -version 2.0 为什么有效。 ISE 一定认为您是在非交互式地调用它。

请注意,它没有结冰。它正在等待进程结束。您可以按 Ctrl+C.

结束它

使用 Start-Process powershell.exe -ArgumentList "-Version 2.0" 打开一个新控制台 window。