Mastering Windows Server 2016 Hyper-V

(Romina) #1

PS C:> $resources = Get‐AzureRmResourceProvider ‐ProviderNamespace
Microsoft.Compute
PS C:> $resources.ResourceTypes.Where{($_.ResourceTypeName ‐eq
'virtualMachines')}.Locations
East US
East US 2
West US
Central US
North Central US
South Central US
North Europe
West Europe
East Asia
Southeast Asia
Japan East
Japan West
Brazil South
Canada Central
Canada East
West US 2
West Central US


Using an image from the Marketplace is a little more complex than in the past with
Azure Service Manager. The process consists of selecting a region, viewing the
available publishers, viewing the images offered by the publisher, viewing the SKUs of
the published image, and then selecting an image. Here is an example of selecting a
Windows Server 2012 R2 image:


$loc = 'SouthCentralUS'
#View the templates available
Get-AzureRmVMImagePublisher -Location $loc
Get-AzureRmVMImageOffer -Location $loc -PublisherName "MicrosoftWindowsServer" Get-AzureRmVMImageSku -Location $loc
-PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer"
Get-AzureRmVMImage -Location $loc -PublisherName "MicrosoftWindowsServer"
-Offer "WindowsServer" -Skus "2012-R2-Datacenter"
$AzureImage = Get-AzureRmVMImage -Location $loc -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer"
-Skus "2012-R2-Datacenter" -Version "4.0.20160617"
$AzureImage


An easy way always to get the latest version of an image is the following:


$AzureImageSku = Get-AzureRmVMImage -Location $loc -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer"
-Skus "2012-R2-Datacenter"
$AzureImageSku = $AzureImageSku | Sort-Object Version -Descending
$AzureImage = $AzureImageSku[0] #Newest


At this point, a VM can be created by using PowerShell. The following code uses an
existing virtual network and storage account based on the names in the variable, along
with the image selected, using the previous example that found an image and assigned

Free download pdf