azure - 通过 Powershell 脚本检查具有不同资源的已停止 VM
问题描述
如何通过 azure powershell 脚本检查已停止的具有不同资源的虚拟机 iam 尝试执行该脚本,请帮助我
解决方案
要获取虚拟机的状态,您可以尝试以下脚本:
#login
Connect-AzureRmAccount
Select-AzureRmSubscription –SubscriptionName 'subscription-name'
Get-AzureRmVM -Status | Format-Table
如果您希望 ResourceGroup 组明智,请尝试以下脚本:
Connect-AzureRmAccount
Select-AzureRmSubscription –SubscriptionName 'subscription-name'
$RG = "ResourceGroupName"
$VM = "vmname"
$VMStats = (Get-AzureRmVM -Name $VM -ResourceGroupName $RG -Status).Statuses
($VMStats | Where Code -Like 'PowerState/*')[0].DisplayStatus
推荐阅读
- javascript - 在 highcharts 中重复使用相同的图表对象以最小化编码
- ios - 使一个部分在其他部分的 Button 操作上可见
- c++ - 您如何使用模板类测试运行您的 c++/Qt 程序/项目?(2020年自动化单元测试)
- python - 向 Discord 文本文件发出 get 请求以获取文件内容
- postgresql - COALESCE 类型字符变化和数字无法匹配
- batch-file - 为什么批处理有时不会像 CMD 那样处理命令并给出意想不到的不同结果
- amazon-web-services - AWS 请求签名是否隐藏了访问密钥?
- javascript - 在 Moodle 中将变量值从 php 发送到 js 脚本的最佳方式
- lua - Kong-OIDC 插件安装问题
- python - Pyspark数据框将函数应用于一行并将行添加到数据框的底部