Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Set-AzureVMSourceImage

Set-AzureVMSourceImage

microsoft.azure.commands.compute.dll

Synopsis

Specify the VM Image to be used for the VM

Syntax

Set-AzureVMSourceImage [-VM] [-PublisherName] [-Offer] [-Skus] [-Version] [-Profile] [-InformationAction] [-InformationVariable] [<CommonParameters>]

Set-AzureVMSourceImage [-VM] [-Name] [-Profile] [-InformationAction] [-InformationVariable] [<CommonParameters>]

Detailed Description

Specify the VM Image to be used for the VM

Parameters

-VM <PSVirtualMachine>

The local VM object to be configured

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByValue, ByPropertyName)

Accept wildcard characters?

false

-PublisherName <String>

Name of the Publisher to be used for the VMImage. Can be discovered using the Get-AzureVMImagePublisher cmdlet

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Offer <String>

Name of the Offer to be used for the VMImage. Can be discovered using the Get-AzureVMImageOffer cmdlet

Aliases

None

Required?

true

Position

2

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Skus <String>

Name of the SKU to be used for the VMImage. Can be discovered using the Get-AzureVMImageSku cmdlet

Aliases

None

Required?

true

Position

3

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Version <String>

Name of the Version to be used for the VMImage. Can be discovered using the Get-AzureVMImage cmdlet

Aliases

None

Required?

true

Position

4

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Profile <AzureProfile>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-InformationAction <ActionPreference>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-InformationVariable <String>

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

false

-Name <String>

Name of the Source Image

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-ImageReference <psvirtualmachineimage>

Image reference to use for the VM. This is an object that can be passed in from the return of the Get-AzureVMImage or the Get-AzureVMImageDetail cmdlet

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue, ByPropertyName)

Accept wildcard characters?

false

-DestinationVhdsContainer <string>

Container to be used for storing VHDs while creating a VM from platform image. Container will be created by CRP if it doesn’t exist already.

Aliases

None

Required?

false

Position

2

Default value

None

Accept pipeline input?

true (ByValue, ByPropertyName)

Accept wildcard characters?

false

Input Type


Return Type


Notes

Examples

-------------------------- Example 1 --------------------------

# Create the VM object
$vm =  New-AzureVMConfig –VMName “myVM” –VMSize “Standard_A1"

# Set the PublisherName, Offer, SKU, Version which can be discovered by the Get-AzureVMImagePublisher, Get-AzureVMImageOffer, Get-AzureVMSku, Get-AzureVMImage cmdlets
Set-AzureVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"

-------------------------- Example 2 --------------------------

Set source image using the image reference method

$loc = "eastasia";
$query = '*Microsoft*Windows*Server';

$publisher = (Get-AzureVMImagePublisher -Location $loc) | select -ExpandProperty PublisherName | where { $_ -like $query };
$offer = (Get-AzureVMImageOffer -Location $loc -PublisherName $publisher[0]) | select -ExpandProperty Offer | where { $_ -like '*Windows*' };
$sku = (Get-AzureVMImageSku -Location $loc -PublisherName $publisher[0] -Offer $offer[0]) | select -ExpandProperty Skus;
$versions = (Get-AzureVMImage -Location $loc -Offer -Offer $offer[0] -PublisherName $publisher[0] -Skus $sku[0]) | select -ExpandProperty Version;
$vmimg = Get-AzureVMImageDetail -Location $loc -Offer -Offer $offer[0] -PublisherName $publisher[0] -Skus $sku[0] -Version $versions[0];

$vm = Set-AzureVMSourceImage -VM $vm -ImageReference $vmimg;

-------------------------- Example 3 --------------------------

$vhdContainer = "https://$stoname.blob.core.windows.net/test";

Switch-AzureMode AzureServiceManagement
Get-AzureVMImage
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201410.01-en.us-127GB.vhd';
Switch-AzureMode AzureResourceManager

Set-AzureVMSourceImage -VM $vm -Name $img -DestinationVhdsContainer $vhdContainer;