Buy Me a Coffee

Buy Me a Coffee!

Wednesday, May 14, 2014

Needle in a Haystack, picking the Azure VM to create in PowerShell

The Powershell script for building out a Lab in Azure is coming along, but now I need to start creating VMs.  That means I need to know which base image to use, and there are a bunch of them!  A quick count shows there to be 214 visible to me right now:

PS C:\users\Larry\Documents\Blog> $vms = Get-AzureVMImage

PS C:\users\Larry\Documents\Blog> $vms.Count
How do I pick one?  You can cut it down by adding a Where-Object to filter it, this one cuts it to 115:

| Where-Object{$_.OS -eq "Windows" -and $_.Category -eq "public"}

Keep playing around with the filter (add a | Select Label to the end to make it easier to look through) until you can find a specific label that somewhat matches what you see on the portal.

Get-AzureVMImage | Where-Object{$_.OS -eq "Windows" -and $_.Label -like "*Windows Server 2012 R2*" -and $_.Category -eq "Public" } | Select Label
Once you find the label that matches what you want, refine the filter and return the full set of data and note the ImageName.  That is what you will use to create your VM.

Get-AzureVMImage | Where-Object{$_.OS -eq "Windows" -and $_.Label -eq "Windows Server 2012 R2 Datacenter, April 2014" }

AffinityGroup        :
Category             : Public
Location             : East Asia;Southeast Asia;Brazil South;North Europe;West
                       Europe;Japan East;Japan West;East US;West US
LogicalSizeInGB      : 128
Label                : Windows Server 2012 R2 Datacenter, April 2014
MediaLink            :
ImageName            : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2
OS                   : Windows
Eula                 :
Description          : At the heart of the Microsoft Cloud OS vision, Windows
                       Server 2012 R2 brings Microsoft's experience delivering
                       global-scale cloud services into your infrastructure.
                       It offers enterprise-class performance, flexibility for
                       your applications and excellent economics for your
                       datacenter and hybrid cloud environment. This image
                       includes Windows Server 2012 R2 Update.
ImageFamily          : Windows Server 2012 R2 Datacenter
PublishedDate        : 4/16/2014 8:00:00 PM
IsPremium            : False
IconUri              : WindowsServer2012R2_45.png
PrivacyUri           :
RecommendedVMSize    :
PublisherName        : Microsoft Windows Server Group
OperationDescription : Get-AzureVMImage
OperationId          : 2bfee615-2150-9b9d-9c71-845a671a246b
OperationStatus      : Succeeded