Skip to content

Instantly share code, notes, and snippets.

@peteraritchie
Created November 14, 2022 15:00
Show Gist options
  • Save peteraritchie/290d34afd058db47bf0f50a0d2fec5c9 to your computer and use it in GitHub Desktop.
Save peteraritchie/290d34afd058db47bf0f50a0d2fec5c9 to your computer and use it in GitHub Desktop.
# create and add a VM data disk
$myRgName = "resourceGroup"
$myVMName = "VM1"
$newDiskName = "data2"
Add-AzVMDataDisk -VM $myVM -Name $newDiskName -LUN 1 -DiskSizeinGB 1 -CreateOption Empty
Update-AzVM -ResourceGroupName $myRGName -VM $myVM
# change caching of a VM Data disk
Set-AzVMDataDisk -VM $myVM -Lun "1" -Caching ReadWrite
Update-AzVM -ResourceGroupName $myRGName -VM $myVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment