![]()
If you don’t know what Changed Block Tracking is, just read this excellent post from Eric Siebert.
You can check the status of Changed Block Tracking with the following PowerCLI one-liner:
Get-VM | Get-View | ` Sort Name | Select Name, ` @{N="ChangeTrackingStatus";E={$_.Config.ChangeTrackingEnabled}}
The output of the one-liner will look like this:
If you’re running a VM with only one VMDK, you can use the following function to enable Changed Block Tracking:
Function EnableChangeTracking{ param($vm) $vmView = Get-VM $vm | Get-View if($vmView.Config.Version -eq "vmx-04"){ Write-Host -ForegroundColor Red ` "The Virtual Hardware version of this VM does not support Changed Block Tracking" return } $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.changeTrackingEnabled = $true $vmView.ReconfigVM($vmConfigSpec) sleep 3 Get-VM $vm | New-Snapshot -Name "Temp" sleep 5 Get-VM $vm | Get-Snapshot | Where {$_.Name -eq "Temp"} | Remove-Snapshot -Confirm:$false }
You can run the function via the following command:
I am going to updated the function later, so it will be able to enable Changed Block Tracking on a VM with multiple VMDKs.
Update: When the VM is powered off, you are able to set the Changed Block Tracking feature for all the VMDKs.
Update 2: There was a little chat about this subject on Twitter between @lamw @gabvirtualworld and me (@afokkema) where @gabvirtualworld posted the following tweet:
I can confirm this theory and update my script with this little trick. Now you’re able to enable Changed Block Tracking when your VM is powered on.