首页 > 解决方案 > Powershell 输出抑制

问题描述

我试图使用 psexec + powershell 在远程机器上启用 WinRM,但它给了我一个我无法抑制的不需要的输出。

C:\psexec\PsExec64.exe -nobanner -accepteula \\computer1 powershell.exe Stop-Service winrm

并得到了我想要抑制的输出:

C:\psexec\PsExec64.exe : Connecting to computer1...
At line:1 char:1
+ C:\psexec\PsExec64.exe -nobanner -accepteula \\computer1 powershell.exe  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Connecting to computer1...:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
Starting PSEXESVC service on computer1...
Connecting with PsExec service on computer1...
Starting powershell.exe on computer1...
powershell.exe exited on computer1 with error code 0.

我尝试了正常的 powershell 错误处理,但没有奏效。

有任何想法吗?

标签: powershellpsexec

解决方案


推荐阅读