Share This Post

Azure / PowerShell

PowerShell Script to Retrieve Name, CPU, RAM size, and OS Disk Size for Azure VMs

PowerShell Script to Retrieve Name, CPU, RAM size, and OS Disk Size for Azure VMs
Subscribe
Voiced by Amazon Polly

Use this PowerShell script to retrieve VM Name, CPU, RAM size, and OS Disk Size.

foreach($VM in (Get-AzVM)){

$size = Get-AzVMSize -Location $VM.Location | Where { $_.Name -eq $VM.HardwareProfile.VmSize}

[PSCustomObject]@{ “Name”=$VM.Name; “CPU”=$size.NumberOfCores; “RAM”=$size.MemoryInMB; “OSDiskSize” = $size.OSDiskSizeInMB; }

}

Share This Post

Leave a Reply