Wanted to share a quick post with a script I seem to use all the time to get a spreadsheet with all the available VM sizes available for use in each region.
  • SYNOPSIS
    This script loads Azure VMs into a Sharepoint Online list.

  • DESCRIPTION
    Retrieves a list of all Azure locations and gets the available VM sizes for each.
    Outputs the results and exports to csv file

  • MODULES
    AzureRM >= 3.6.0

  • VARIABLES
    $ExportFilePath: Currently set to temp folder

     

    PowerShell
    Edit|Remove
      
    $ExportFilePath = "$($Env:Temp)\AzureVMSizes.csv" 
     
    $VMSizeList = New-Object collections.ArrayList 
    $Locns = Get-AzureRmLocation 
    foreach ($Locn in $Locns) { 
         
        $VMSizes = Get-AzureRmVMSize -Location $Locn.Location  
        Write-Output "Locn: $($Locn.DisplayName) - $($VMSizes.Count) records" 
        foreach ($VMSize in $VMSizes) { 
            $SizeListEntry = new-object psobject -Property @{ 
                Location = $($Locn.DisplayName) 
                Name = $VMSize.Name 
                NumberOfCores = $VMSize.NumberOfCores 
                MemoryInMB = $VMSize.MemoryInMB 
                MaxDataDiskCount = $VMSize.MaxDataDiskCount 
                OSDiskSizeInMB = $VMSize.OSDiskSizeInMB 
                ResourceDiskSizeInMB = $VMSize.ResourceDiskSizeInMB 
            } 
            $VMSizeList.Add($SizeListEntry| Out-Null  
        } 
         
    } 
     
    $VMSizeList | Select-Object Location, Name, NumberOfCores, MemoryInMB, MaxDataDiskCount, OSDiskSizeInMB, ResourceDiskSizeInMB | format-table -AutoSize 
    $VMSizeList | Select-Object Location, Name, NumberOfCores, MemoryInMB, MaxDataDiskCount, OSDiskSizeInMB, ResourceDiskSizeInMB | Export-Csv -Path $ExportFilePath -NoTypeInformation 
    Invoke-Item $ExportFilePath