在powershell(2.0)下面的作品很好,罚款:CMD / C回声“你好”| selectstring你好
输出“你好”。
在远程处理模式下运行时,文本不会被打印:
Invoke-Command -ComputerName myserver -Credential [email protected] { cmd /c echo "hello" | select-string hello }
为什么,以及如何在远程处理模式下grep命令的文本(exefiles)? (客户端的Windows7,服务器的2008r2,命令可以正常运行,端口是开放的等)
你不想做:
Invoke-Command -ComputerName localhost { cmd /c echo "hello"} | select-string "hello"
Select-String的输出不是一个string,而是一个MatchInfo ,不能通过Invoke-Command连接返回。
只需将Select-String的结果Out-String到Out-String ,就会得到你的输出〜:
Invoke-Command -ComputerName myserver -Credential [email protected] { cmd /c echo "hello" | select-string hello | out-string }