< Back

Set-AzureRmVMOSDisk

Tue Jan 29, 2019 9:40 pm

NAME Set-AzureRmVMOSDisk



SYNOPSIS

Sets the operating system disk properties on a virtual machine.





SYNTAX

Set-AzureRmVMOSDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-KeyEncryptionKeyVaultId] <String>] [[-VhdUri] <String>] [[-Caching] {None |

ReadOnly | ReadWrite}] [[-SourceImageUri] <String>] [[-CreateOption] <String>] [[-Windows]] [-DiskEncryptionKeyUrl] <String>

[-DiskEncryptionKeyVaultId] <String> [[-KeyEncryptionKeyUrl] <String>] [-DefaultProfile <IAzureContextContainer>] [-DiskSizeInGB <Int32>]

[-ManagedDiskId <String>] [-StorageAccountType <String>] [-WriteAccelerator] [<CommonParameters>]



Set-AzureRmVMOSDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-KeyEncryptionKeyVaultId] <String>] [[-VhdUri] <String>] [[-Caching] {None |

ReadOnly | ReadWrite}] [[-SourceImageUri] <String>] [[-CreateOption] <String>] [[-Linux]] [-DiskEncryptionKeyUrl] <String>

[-DiskEncryptionKeyVaultId] <String> [[-KeyEncryptionKeyUrl] <String>] [-DefaultProfile <IAzureContextContainer>] [-DiskSizeInGB <Int32>]

[-ManagedDiskId <String>] [-StorageAccountType <String>] [-WriteAccelerator] [<CommonParameters>]



Set-AzureRmVMOSDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-VhdUri] <String>] [[-Caching] {None | ReadOnly | ReadWrite}] [[-SourceImageUri]

<String>] [[-CreateOption] <String>] [[-Linux]] [-DefaultProfile <IAzureContextContainer>] [-DiskSizeInGB <Int32>] [-ManagedDiskId <String>]

[-StorageAccountType <String>] [-WriteAccelerator] [<CommonParameters>]



Set-AzureRmVMOSDisk [-VM] <PSVirtualMachine> [[-Name] <String>] [[-VhdUri] <String>] [[-Caching] {None | ReadOnly | ReadWrite}] [[-SourceImageUri]

<String>] [[-CreateOption] <String>] [[-Windows]] [-DefaultProfile <IAzureContextContainer>] [-DiskSizeInGB <Int32>] [-ManagedDiskId <String>]

[-StorageAccountType <String>] [-WriteAccelerator] [<CommonParameters>]





DESCRIPTION

The Set-AzureRmVMOSDisk cmdlet sets the operating system disk properties on a virtual machine.





PARAMETERS

-Caching <CachingTypes>

Specifies the caching mode of the operating system disk. Valid values are:



- ReadOnly



- ReadWrite





The default value is ReadWrite. Changing the caching value causes the virtual machine to restart.

This setting affects the performance of the disk.





Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-CreateOption <String>

Specifies whether this cmdlet creates a disk in the virtual machine from a platform or user image, or attaches an existing disk. Valid values

are:



- Attach. Specify this option to create a virtual machine from a specialized disk. When you specify this option, do not specify the

SourceImageUri parameter. Instead, use the Set-AzureRmVMSourceImage cmdlet. You must also use the use the Windows or Linux parameters to tell

the azure2 platform the type of the operating system on the VHD. The VhdUri parameter is enough to tell the azure2 platform the location of

the disk to attach. - FromImage. Specify this option to create a virtual machine from a platform image or a generalized user image. In the

case of a generalized user image, you also need to specify the SourceImageUri parameter and either the Windows or Linux parameters to tell the

Azure platform the location and type of the operating system disk VHD instead of using the Set-AzureRmVMSourceImage cmdlet. In the case of a

platform image, the VhdUri parameter is sufficient. - Empty.



Required? false

Position? 5

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DiskEncryptionKeyUrl <String>

Specifies the location of the disk encryption key.



Required? true

Position? 7

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DiskEncryptionKeyVaultId <String>

Specifies the resource ID of the Key Vault containing the disk encryption key.



Required? true

Position? 8

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DiskSizeInGB <Int32>

Specifies the size, in GB, of the operating system disk.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-KeyEncryptionKeyUrl <String>

Specifies the location of the key encryption key.



Required? false

Position? 9

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-KeyEncryptionKeyVaultId <String>

Specifies the resource ID of the Key Vault containing the key encryption key.



Required? false

Position? 10

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Linux [<SwitchParameter>]

Indicates that the operating system on the user image is Linux. Specify this parameter for user image based virtual machine deployment.



Required? false

Position? 6

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-ManagedDiskId <String>

Specifies the ID of a managed disk.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Name <String>

Specifies the name of the operating system disk.



Required? false

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-SourceImageUri <String>

Specifies the URI of the VHD for user image scenarios.



Required? false

Position? 4

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-StorageAccountType <String>

Specifies the storage account type of managed disk.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VhdUri <String>

Specifies the Uniform Resource Identifier (URI) of a virtual hard disk (VHD).



For an image based virtual machine, this parameter specifies the VHD file to create when a platform image or user image is specified. This is

the location from which the image binary large object (BLOB) is copied to start the virtual machine.



For a disk based virtual machine boot scenario, this parameter specifies the VHD file that the virtual machine uses directly for starting up.



Required? false

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-VM <PSVirtualMachine>

Specifies the local virtual machine object on which to set operating system disk properties. To obtain a virtual machine object, use the

Get-AzureRmVM cmdlet.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Windows [<SwitchParameter>]

Indicates that the operating system on the user image is Windows.



Required? false

Position? 6

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-WriteAccelerator [<SwitchParameter>]

Specifies whether WriteAccelerator should be enabled or disabled on the OS disk.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

PSVirtualMachine

Parameter 'VM' accepts value of type 'PSVirtualMachine' from the pipeline





OUTPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine







NOTES









Example 1: Set properties on a virtual machine from platform image



PS C:\\> $AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"

PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1" -AvailabilitySetID $AvailabilitySet.Id

PS C:\\> Set-AzureRmVMOSDisk -VM $VirtualMachine -Name "OsDisk12" -VhdUri "os.vhd" -Caching ReadWrite

PS C:\\> $VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Linux -ComputerName "MainComputer" -Credential (Get-Credential)

PS C:\\> $VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName "Canonical" -Offer "UbuntuServer" -Skus "15.10" -Version

"latest" -Caching ReadWrite

PS C:\\> $VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -VhdUri

"https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption FromImage

PS C:> New-AzureRmVM -VM $VirtualMachine -ResouceGroupName "ResourceGroup11"



The first command gets the availability set named AvailablitySet13 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 the properties on the virtual machine in $VirtualMachine.





Example 2: Sets properties on a virtual machine from generalized user image



PS C:\\> $AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"

PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"

PS C:\\> $VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Linux -ComputerName "MainComputer" -Credential (Get-Credential)

PS C:\\> $VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -SourceImageUri

"https://mystorageaccount.blob.core.wind ... SImage.vhd" -VhdUri "https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption

fromImage -Linux

PS C:> New-AzureRmVM -VM $VirtualMachine -ResouceGroupName "ResourceGroup11"



The first command gets the availability set named AvailablitySet13 in the resource group named ResourceGroup11 and stores that object in the

$AvailabilitySet variable. The second command creates a virtual machine object and 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 the

properties on the virtual machine in $VirtualMachine.





Example 3: Sets properties on a virtual machine from specialized user image



PS C:\\> $AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName "ResourceGroup11" -Name "AvailabilitySet13"

PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"

PS C:\\> $VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name "osDisk.vhd" -VhdUri

"https://mystorageaccount.blob.core.windows.net/disks/" -CreateOption Attach -Linux

PS C:> New-AzureRmVM -VM $VirtualMachine -ResouceGroupName "ResourceGroup11"



The first command gets the availability set named AvailablitySet13 in the resource group named ResourceGroup11 and stores that object in the

$AvailabilitySet variable. The second command creates a virtual machine object and 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 the

properties on the virtual machine in $VirtualMachine.





Example 4: Set the disk encryption settings on a virtual machine operating system disk



PS C:\\> $VirtualMachine = New-AzureRmVMConfig -VMName "VirtualMachine17" -VMSize "Standard_A1"

PS C:> $VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name "OsDisk12" -VhdUri "os.vhd" -Caching ReadWrite -Windows -CreateOption

"Attach" -DiskEncryptionKeyUrl "https://mytestvault.vault.azure.net/sec ... 0bddaaaaaa" -DiskEncryptionKeyVaultId

"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.KeyVault/vaults/mytestvault"

PS C:> New-AzureRmVM -VM $VirtualMachine -ResouceGroupName " ResourceGroup11"



This example sets the disk encryption settings on a virtual machine operating system disk.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... rmvmosdisk

Get-AzureRmVmssDiskEncryption

Get-AzureRmAvailabilitySet

New-AzureRmVMConfig