Script to Reset CBT on a Single VM in VMware

I wanted to reset CBT (Change Block Tracking) on a single VM to due to the VMware bug (KB2090639) which affects any VMs that have expanded disks over 128GB. Using this script over the manual option prevents the restart of the VM as the modification is performed online using a Power CLI script.


In the below example the VM in question is called "MyVMName"

$targetvms=get-vm -Name MyVMName | where {$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}
$vmspec = New-Object VMware.Vim.VirtualMachineConfigSpec 
$vmspec.ChangeTrackingEnabled = $false
foreach($vm in $targetvms){ 
    $snap=$vm | New-Snapshot -Name 'CBT Reset for VMware Bug' 
    $snap | Remove-Snapshot -confirm:$false}


Note: Please use at own risk.