Set-AzureVMSourceImage

Set-AzureVMSourceImage

Specifies the platform image for a virtual machine.

Syntax

Parameter Set: ImageReferenceParameterSet
Set-AzureVMSourceImage [-VM] <Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine> [-PublisherName] <System.String> [-Offer] <System.String> [-Skus] <System.String> [-Version] <System.String> [-Profile <Microsoft.Azure.Common.Authentication.Models.AzureProfile> ] [ <CommonParameters>]

Parameter Set: SourceImageParameterSet
Set-AzureVMSourceImage [-VM] <Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine> [-Name] <System.String> [-Profile <Microsoft.Azure.Common.Authentication.Models.AzureProfile> ] [ <CommonParameters>]

Detailed Description

The Set-AzureVMSourceImage cmdlet specifies the platform image to use for a virtual machine.

Parameters

-Name<System.String>

Specifies the name of a source image.

Aliases

SourceImageName,ImageName

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Offer<System.String>

Specifies the type of VMImage offer. To obtain an image offer, use the Get-AzureVMImageOffer cmdlet.

Aliases

none

Required?

true

Position?

3

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Profile<Microsoft.Azure.Common.Authentication.Models.AzureProfile>

Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PublisherName<System.String>

Specifies the name of a publisher of a VMImage. To obtain a publisher, use the Get-AzureVMImagePublisher cmdlet.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Skus<System.String>

Specfies a VMImage SKU. To obtain SKUs, use the Get-AzureVMImageSku cmdlet.

Aliases

none

Required?

true

Position?

4

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-Version<System.String>

Specifies a version of a VMImage. To use the latest version, specify a value of latest instead of a particular version.

Aliases

none

Required?

true

Position?

5

Default Value

none

Accept Pipeline Input?

true(ByPropertyName)

Accept Wildcard Characters?

false

-VM<Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine>

Specifies the local virtual machine object to configure.

Aliases

VMProfile

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true(ByValue,ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Set values for an image

The first command gets the availability set named AvailablitySet03 in the resource group named ResourceGroup11, and then stores that object in the $AvailabilitySet variable.

The second command creates a virtual machine object, and then stores it in the $VirtualMachine variable. The command assigns a name and size to the virtual machine. The virtual machine belongs to the availability set stored in $AvailabilitySet.

The final command sets values for publisher name, offer, SKU, and version. The Get-AzureVMImagePublisher, Get-AzureVMImageOffer, Get-AzureVMImageSku, and Get-AzureVMImage cmdlets can discover these settings.

AvailabilitySet = Get-AzureAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"
PS C:\> $VirtualMachine = New-AzureVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id 
PS C:\> Set-AzureVMSourceImage -VM $VirtualMachine -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2012-R2-Datacenter" -Version "latest"

Example 2: Use the image reference method to set values

This example sets source image settings by using the image reference method.

$Publisher = (Get-AzureVMImagePublisher -Location "Central US") | select -ExpandProperty PublisherName | where { $_ -like '*Microsoft*Windows*Server' } 
PS C:\> $Offer = (Get-AzureVMImageOffer -Location "Central US" -PublisherName $Publisher[0]) | select -ExpandProperty Offer | where { $_ -like '*Windows*' } 
PS C:\> $Sku = (Get-AzureVMImageSku -Location "Central US" -PublisherName $Publisher[0] -Offer $Offer[0]) | select -ExpandProperty Skus
PS C:\> $Versions = (Get-AzureVMImage -Location "Central US" -Offer -Offer $Offer[0] -PublisherName $Publisher[0] -Skus $Sku[0]) | select -ExpandProperty Version
PS C:\> $VMImage = Get-AzureVMImageDetail -Location "Central US" -Offer -Offer $Offer[0] -PublisherName $Publisher[0] -Skus $Sku[0] -Version $Versions[0] 
PS C:\> $VirtualMachine07 = Set-AzureVMSourceImage -VM $VirtualMachine07 -ImageReference $VMImage

Get-AzureAvailabilitySet

New-AzureVMConfig

Get-AzureVMImagePublisher

Get-AzureVMImageOffer

Get-AzureVMImageSku

Get-AzureVMImage