簡體   English   中英

使用psexec作為腳本啟用PowerShell遠程處理

[英]Enabling PowerShell Remoting with psexec as script

如果我跑:

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 

}

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM