Skip to content

Instantly share code, notes, and snippets.

Embed
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
# https://docs.microsoft.com/en-us/azure/virtual-machines/sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment