powershell.exe -version 2.0正在冻结ISE&控制台(第4版)

时间:2015-01-14 13:26:49

标签: powershell

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

以下内容只是冻结了应用程序:

PS H:\> powershell.exe -version 2.0

我确实收到了以下文字,但控制台继续运行,我无法执行更多脚本。

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

1 个答案:

答案 0 :(得分:2)

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

请注意,当您尝试运行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

同样,单独运行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"打开一个新的控制台窗口。

相关问题