【发布时间】:2021-03-03 15:17:01
【问题描述】:
我有一个天蓝色的虚拟机。我正在编写一个执行两个 .bat 文件的 powershell 脚本,之后它必须重新启动 azure VM,之后它必须继续执行剩余的 .bat 文件。
这是下面的脚本
第一步:set-location -path C:/temp
第二步:start-process cmd.exe /c "abc.bat" -wait
第三步:start-process cmd.exe /c "123.bat" -wait
第四步:restart-computer -Force
第五步:start-process cmd.exe /c "prod.bat" -wait
第六步:start-process cmd.exe /c "dev.bat" -wait
我通过下面的命令远程执行这个脚本
PS C:\> Invoke-AzVMRunCommand -ResourceGroupName 'rgname' -VMName 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath '/Users/username/sample.ps1'
运行上述命令后,它的执行正常到“第 4 步”。之后不再继续执行其余步骤
你能帮我解决这个问题吗?
【问题讨论】:
标签: azure powershell automation