【发布时间】:2025-12-04 13:05:02
【问题描述】:
这不是 this question 的重复项,因为在 MS 做出破坏向后兼容性的更改后,该解决方案不再有效。
我需要以编程方式(通过 Azure Powershell)启动/停止以编程方式(通过 Azure Powershell)创建的 VM。文档说我需要提供一个“服务名称”,但我找不到任何关于如何从 VM 获取它的参考:
Stop-AzureVM -ServiceName $hostname -Name $hostname
Start-AzureVM -ServiceName $hostname -Name $hostname
文档还建议使用Get-AzureService 并且(我认为)允许我提供配置文件而不是服务。但是,使用Select-AzureRmProfile 只能获得Microsoft.Azure.Commands.Profile.Models.PSAzureProfile,而Get-AzureService 需要Microsoft.Azure.Commands.Profile.Models.PSAzureSMProfile。我被卡住了。
帮助?
【问题讨论】:
标签: powershell azure virtual-machine