Skip to content

Instantly share code, notes, and snippets.

Last active January 18, 2021 14:13
What would you like to do?
Retrieve a list of Azure VM and their VM Size in a specific Resource Group
function ListRGVMsizes($Rg, $VmSize)
if($Rg.Length -gt 0){
$VMs = Get-AzVM -ResourceGroupName $Rg
foreach($vm in $VMs){
if ($vm.HardwareProfile.VmSize -like "*"+$VmSize+"*"){
Write-host $vm.Name ": " $vm.HardwareProfile.VmSize
#this example will search for all VMs that are of "B" Series
ListRGVMsizes "resource-group-name-here" "_B"
# Check this link for valid Azure VM Sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment