Enable Change Block Tracking via PowerCLI Scipt

Issue: You need to enable Change Block Tracking (CBT) on numerous virtual machines and have it take effect immediately.

Background: Enabling change block tracking does not take effect immediately and requires a suspend/resume or snapshot create/delete.  This process of changing the CBT setting and activating the change becomes incredibly time consuming.

Solution: Enable Change Block Tracking via PowerCLI Script

  1. Copy the below txt and paste into a text file with extension .ps1.  Place this file in an easy to browse to location for example c:\CBT-SCRIPT
# remember to connect to VCenter server: Connect-VIServer -Server vcenter01

#show current change block tracking status
Get-VM | Get-View | Sort Name | Select Name, @{N="ChangeTrackingStatus";E={$_.Config.ChangeTrackingEnabled}}

$targets = Get-VM | Select Name, @{N="CBT";E={(Get-View $_).Config.ChangeTrackingEnabled}} | WHERE {$_.CBT -like "False"}
ForEach ($target in $targets) {
 $vm = $target.Name
 Get-VM $vm | Get-Snapshot | Remove-Snapshot -confirm:$false
 $vmView = Get-vm $vm | get-view
 $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
 $vmConfigSpec.changeTrackingEnabled = $true
 New-Snapshot -VM (Get-VM $vm ) -Name "CBTSnap"
 Get-VM $vm | Get-Snapshot -Name "CBTSnap" | Remove-Snapshot -confirm:$false

#show change block tracking status again
Get-VM | Get-View | Sort Name | Select Name, @{N="ChangeTrackingStatus";E={$_.Config.ChangeTrackingEnabled}}

Note: I make no warranties and take no responsibility for your use of scripts.  Use your judgement and expertise to review the scripted command and determine the applicability and ramifications in your environment.

  1. Launch VMWare PowerCLI on your VCenter Server
  2. Browse to the folder with the script
  3. Use the following command to connect to VCenter
    Connect-VIServer -Server <VCENTERSERVERNAME>



3 thoughts on “Enable Change Block Tracking via PowerCLI Scipt

    1. Chris Post author

      I don’t see any code in the scripts that would initiate a reboot. This script opts to create and remove a snapshot in order to make the change active so a reboot is not necessary.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.