Set-AzureRmVMSourceImage
Specifies the image for a virtual machine.
Important
You've reached a webpage for an outdated version of Azure PowerShell. All versions of the AzureRM PowerShell module are outdated, but not out of support. The Az PowerShell module is now the recommended PowerShell module for interacting with Azure. To get started with the Az PowerShell module, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.
Syntax
Set-AzureRmVMSourceImage
[-VM] <PSVirtualMachine>
[-PublisherName] <String>
[-Offer] <String>
[-Skus] <String>
[-Version] <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Set-AzureRmVMSourceImage
[-VM] <PSVirtualMachine>
[-Id] <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Set-AzureRmVMSourceImage cmdlet specifies the platform image to use for a virtual machine.
Examples
Example 1: Set values for an image
PS C:\> $AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet03"
PS C:\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine07" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id
PS C:\> Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2012-R2-Datacenter" -Version "latest"
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-AzureRmVMImagePublisher, Get-AzureRmVMImageOffer, Get-AzureRmVMImageSku, and Get-AzureRmVMImage cmdlets can discover these settings.
Parameters
The credentials, account, tenant, and subscription used for communication with azure.
Type: | Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer |
Aliases: | AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the ID.
Type: | String |
Position: | 1 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the type of VMImage offer. To obtain an image offer, use the Get-AzureRmVMImageOffer cmdlet.
Type: | String |
Position: | 2 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of a publisher of a VMImage. To obtain a publisher, use the Get-AzureRmVMImagePublisher cmdlet.
Type: | String |
Position: | 1 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies a VMImage SKU. To obtain SKUs, use the Get-AzureRmVMImageSku cmdlet.
Type: | String |
Position: | 3 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies a version of a VMImage. To use the latest version, specify a value of latest instead of a particular version.
Type: | String |
Position: | 4 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the local virtual machine object to configure.
Type: | PSVirtualMachine |
Aliases: | VMProfile |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |