第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何通過(guò)Powershell異步從遠(yuǎn)程機(jī)器運(yùn)行Python腳本?

如何通過(guò)Powershell異步從遠(yuǎn)程機(jī)器運(yùn)行Python腳本?

哈士奇WWW 2021-08-24 14:50:40
我有一個(gè)只能同步工作的 powershell 函數(shù)。我想更新這個(gè)函數(shù),以便我可以并行觸發(fā)對(duì) Python 腳本的多個(gè)調(diào)用。有沒(méi)有人知道如何使用 powershell 異步調(diào)用 Python 腳本,記住每個(gè) Python 腳本本質(zhì)上都是一個(gè) while 循環(huán),直到 24 小時(shí)后才結(jié)束。powershell 函數(shù)接收遠(yuǎn)程機(jī)器、python 虛擬環(huán)境、python 腳本的路徑和參數(shù)。以下是迄今為止所做的工作:function Run-Remote($computerName, $pname, $scriptPath, $pargs){    $cred = Get-QRemote-Credential    Invoke-Command -ComputerName $computerName -Credential $cred -ScriptBlock {powershell -c "$Using:pname '$Using:scriptPath' $Using:pargs"} -ConfigurationName QRemoteConfiguration}
查看完整描述

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


查看完整回答
反對(duì) 回復(fù) 2021-08-24
  • 1 回答
  • 0 關(guān)注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)