Skip to content

Instantly share code, notes, and snippets.

@SQLtattoo
Last active January 18, 2021 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SQLtattoo/6910720a60d3bc23aaf812a5a0f42a35 to your computer and use it in GitHub Desktop.
Save SQLtattoo/6910720a60d3bc23aaf812a5a0f42a35 to your computer and use it in GitHub Desktop.
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