Powershell输出抑制

Powershell输出抑制,powershell,psexec,Powershell,Psexec,我试图使用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\PsExec

我试图使用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错误处理,但没有成功


有什么想法吗?

和{C:\psexec\…}*>$null
它能工作!谢谢你,伙计+1至Mathias的评论-如果您想了解更多关于输出流重定向的信息,请查看此处-