Last active
August 6, 2017 02:57
-
-
Save mrik23/a835bf977e6b9c13440e36045e20478c to your computer and use it in GitHub Desktop.
PowerShell snippet to change the Host Caching option for the OS disk of an existing VM in Azure RM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires Azure PowerShell v2 | |
#Check documentation https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0 | |
#Make sure AzureRM module is installed and loaded | |
Import-Module AzureRM | |
#Connect to Azure | |
Login-AzureRmAccount | |
#Get the current VM config | |
$vm = Get-AzureRmVM -ResourceGroupName "myRG" -VMName "myVM" | |
#Change the Caching option. Possible value None, Read, ReadWrite. | |
$vm.StorageProfile.OsDisk.Caching = "None" | |
#Update the VM config | |
Update-AzureRmVM -VM $vm -ResourceGroupName "myRG" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment