【发布时间】:2016-03-23 19:35:52
【问题描述】:
如果我跑:
C:\psexec.exe \\$compname -s powershell Enable-PSRemoting -Force
作为命令它工作正常,但是一旦我将它放入 foreach 循环中,我就会收到一条错误消息,指出句柄无效。有什么办法解决这个问题?
这是我的循环:
$computerlist = Get-Content C:\computernames\WorkstationList.txt
foreach ($compname in $computerlist){
C:\psexec.exe \\$compname -s powershell Enable-PSRemoting -Force
}
【问题讨论】:
-
您能否提供一些 WorkstationList 中的主机名示例(经过混淆处理,但类似列出 - 包括模糊字符(如果存在)等)?我的猜测是那里的数据没有得到适当的处理。
标签: powershell psexec