# Install the Azure PowerShell module if not already installed
# Install-Module -Name Az -AllowClobber -Scope CurrentUser
# Connect to Azure
Connect-AzAccount
# Set your subscription ID
$subscriptionId = "your-subscription-id"
Select-AzSubscription -SubscriptionId $subscriptionId
# Set the resource group and VM name
$resourceGroupName = "your-resource-group"
$vmName = "your-vm-name"
# Get the VM
$vm = Get-AzVM -ResourceGroupName $resourceGroupName -Name $vmName
# Get the metrics for the VM's disks
Get-AzMetric -ResourceId $vm.Id -MetricNames "Disk Write Operations/sec", "Disk Read Operations/sec", "Disk Write Bytes/sec", "Disk Read Bytes/sec" -TimeGrain "PT1M" -StartTime (Get-Date).AddMinutes(-60) -EndTime (Get-Date)
1 个回答