Get-AzureVM Returns 没有 - 尝试过的建议

Get-AzureVM Returns Nothing - Tried suggestions

出于某种原因,当我 运行 Get-AzureVMGet-AzureRmVm 时,我没有得到任何信息。

我使用以下方式登录:Login-AzureRMAccount。我可以通过 Get-AzureSubscription | select SubscriptionName 查看我的所有订阅。

我运行正在使用最新版本的 Azure Powershell。几天前我使用 Resource Manager 构建了我的虚拟机。

如果您的 Azure 帐户下有多个 Azure 订阅,您首先需要通过以下命令 select Azure 资源管理器 (RM) VM 所在的正确订阅。

Set-AzureRmContext -SubscriptionId <your-subscriptionId> -TenantId <your-tenantId>

您可以通过以下方式查看您的订阅 ID 和租户 ID 列表:

Get-AzureRmSubscription 

设置正确的 Azure Rm 上下文后,您应该可以通过以下方式获取当前订阅上下文下的所有 Azure RM VM:

Get-AzureRmVM

此解决方案已在我的 Azure 订阅和 VM 上使用最新的 Azure PowerShell December 2015 (1.0.2) 进行了测试。

希望对您有所帮助!

如果您在创建虚拟机时选择开发模式是资源管理器而不是经典,则必须使用以下命令列出虚拟机:

Get-AzureRmVM