簡體   English   中英

即使遇到重新啟動,也繼續執行 powershell 腳本

[英]Continue powershell script execution even if a reboot is encountered

所有,我正在嘗試編寫一個腳本來更新遠程機器上的程序,但是升級需要一兩次重新啟動。 當我運行 powershell 腳本時,它會觸發升級並且機器重新啟動一次,重新啟動后升級不會繼續,除非任何用戶帳戶登錄到機器; 發布用戶登錄后,升級會自動恢復,升級過程會觸發另一個升級完成的重啟帖子。

有沒有辦法實現這一目標? 下面是我正在嘗試的。

Invoke-Command -ComputerName $name -ScriptBlock { Unblock-File 'C:\\temp\\Install\\VDAServerSetup_1912.exe'; Start-Process -FilePath C:\\temp\\Install\\VDAServerSetup_1912.exe -ArgumentList '/components VDA', /disableexperiencemetrics, /enable_hdx_ports, /enable_hdx_udp_ports, /enable_real_time_transport, /enable_remote_assistance, '/includeadditional "Citrix Personalization for App-V - VDA"','/exclude "Personal vDisk","Machine Identity Service"', '/includeadditional "Citrix Personalization for App-V - VDA"', '/logpath "c:\\becnet\\xenapp"', /masterimage, /quiet, /virtualmachine, /disableexperiencemetrics, /optimize, /virtualmachine -wait}

我刪除了復制代碼,因為該部分工作正常。 我面臨的問題是,一旦在遠程機器上觸發上述代碼,機器將作為升級的一部分重新啟動,但是一旦機器備份,升級就會卡住,除非有人登錄到機器。 有沒有辦法在無人看管的情況下實現這一目標?

正如下面 Larry 所指出的,我在啟用 Autologon 的情況下取得了成功,但是我想使用該方法作為最后的手段,還有其他方法可以實現嗎?

您沒有正確引用參數。 而 c$ 是一個錯字。 這是固定代碼:

Copy-Item -Path $Source_vda_path -Destination "\\$($name)\C:\$($temp)\Install\VDAServerSetup_1912.exe" -Force
Invoke-Command -ComputerName $name -ScriptBlock "{ & Unblock-File 'C:\temp\Install\VDAServerSetup_1912.exe'; Start-Process -FilePath 'C:\temp\Install\VDAServerSetup_1912.exe' -ArgumentList '/components VDA', '/disableexperiencemetrics', '/enable_hdx_ports', '/enable_hdx_udp_ports', '/enable_real_time_transport', '/enable_remote_assistance', '/includeadditional "Citrix Personalization for App-V - VDA"','/exclude "Personal vDisk","Machine Identity Service"', '/includeadditional "Citrix Personalization for App-V - VDA"', '/logpath "c:\becnet\xenapp"', '/masterimage', '/quiet', '/virtualmachine', '/disableexperiencemetrics', '/optimize', '/virtualmachine', -wait}"

暫無
暫無

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

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