【问题标题】:Enabling PowerShell Remoting with psexec as script使用 psexec 作为脚本启用 PowerShell 远程处理
【发布时间】: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


【解决方案1】:

psexec -@WorkstationList.txt -s powershell Enable-PSRemoting -Force

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多