1 回答

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
修復(fù)非常簡(jiǎn)單,只需在調(diào)用命令中添加“-AsJob”即可。這將使 powershell 為您發(fā)送的每個(gè)命令啟動(dòng)一個(gè)新進(jìn)程。然后在腳本末尾使用“Get-Job | Wait-Job”等待所有進(jìn)程完成。和“Get-Job | Receive-Job”來(lái)取回任何數(shù)據(jù)。
我建議閱讀有關(guān) powershell 的工作,它們非常有用但不直觀。
function Run-Remote($computerName, $pname, $scriptPath, $pargs)
{
$cred = Get-QRemote-Credential
Invoke-Command -AsJob -ComputerName $computerName -Credential $cred -ScriptBlock {powershell -c "$Using:pname '$Using:scriptPath' $Using:pargs"} -ConfigurationName QRemoteConfiguration
}
Get-Job | Wait-Job
添加回答
舉報(bào)