【发布时间】:2021-02-04 17:48:46
【问题描述】:
我们有 2 个 VM,VM1 是原始 VM,VM2 是从 VM1 的快照创建的。
Run Command 在 VM1 上运行良好,但使用 PowerShell Invoke-AzVMRunCommand 执行时会超时。从 Portal 执行“运行命令”时,不会出现任何更改(也不会出现超时)。
这可能是什么原因?
我们正在通过 PowerShell 启动运行命令:
Invoke-AzVMRunCommand -ResourceGroupName Restore-RG -VMName DB-SLV-IMG-VM-LatestRestore-VM -CommandId 'RunPowerShellScript' -ScriptPath C:\Scripts\Script1.ps1
而Script1.ps1的内容是:
. C:\Scripts\TargetScript.ps1
VM1和VM2上TargetScript.ps1的内容是:
New-Item C:\Scripts\File1
【问题讨论】:
-
运行 Azure 自定义脚本扩展失败还是运行命令失败?您能否展示如何运行自定义脚本扩展以及扩展的内容?
-
你说得对,我没有使用 Azure 自定义脚本扩展,而是使用运行命令。我已经编辑了问题以反映这一点。