Retrieve a list of Azure VM and their VM Size in a specific Resource Group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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