【发布时间】:2019-05-25 02:56:42
【问题描述】:
我需要使用 PowerShell 收集 Azure VM 自动关闭时间,但不知道如何获取必要的资源属性以便反映自动关闭时间。
我得到以下输出:
ID: /subscriptions/12345/resourceGroups/W12RG/providers/Microsoft.Compute/virtualMachines/W12
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
shutdown-computevm-W12 W12RG Microsoft.DevTestLab/schedules eastus1
# Retrieve the resource group information
[array]$ResourceGroupArray = Get-AzureRMVm | Select-Object -Property ResourceGroupName, Name, VmId
foreach ($resourceGroup in $ResourceGroupArray){
$targetResourceId = (Get-AzureRmVM -ResourceGroupName $resourcegroup.ResourceGroupName -Name $resourceGroup.Name).Id
$shutdownInformation = Get-AzureRmResource -ResourceGroupName $resourcegroup.ResourceGroupName -ResourceType Microsoft.DevTestLab/schedules | ft
Write-Host "ID: " $targetResourceId
$shutdownInformation
}
我需要收集 Azure VM 的自动关闭时间
【问题讨论】:
标签: powershell azure-powershell