ISSUE
Resetting CBT is an ardous task that requires you to power off the VM and edit VM ctkEnabled property using vSphere Client or use VMware APIs to disable/enable CBT and create/remove a temporary snapshot to purge CBT tables.
We have created a powershell cmdlet that uses VMware PowerCLI to automate this CBT reset operation in one or multiple VMs. As explained the script needs to create/remove a temporary snapshot so it is recommended that you do not run it during production hours on VMs that may be impacted by a VM snapshot.
Running the script and cmdlets
- Download UnitrendsCBT.ps1 script from Unitrends GitHub repo.
- Open PowerCLI (32-bit) console. If you use default PowerCLI console you may get error “Operation is not valid due to the current state of the object” while running CBT-Reset.
- CD to Path where you downloaded UnitrendsCBT.ps1 script.
PowerCLI C:\> cd C:\Unitrends\scripts\CBT
- Allow Execution of unsigned powershell script. (Set-ExecutionPolicy Bypass)
PowerCLI C:\Unitrends\scripts\CBT> Set-ExecutionPolicy Bypass
- Load Cmdlets from UnitrendsCBT.ps1 running command.
PowerCLI C:\Unitrends\scripts\CBT> . .\UnitrendsCBT.ps1
- Connect to VMware server using PowerCLI Connect-VIServer.
PowerCLI C:\Unitrends\scripts\CBT> Connect-VIServer -Server <vsphere server> -User <username> -Password <password>
- Reset-CBT on one or multiple VMS.
PowerCLI C:\Unitrends\scripts\CBT> Get-VM test01|Reset-CBT
Sample Usage and Output
PowerCLI C:\Unitrends\scripts\CBT> Set-ExecutionPolicy Bypass PowerCLI C:\Unitrends\scripts\CBT> Connect-VIServer -Server vcenter01 -User root -Port password PowerCLI C:\Unitrends\scripts\CBT> . .\UnitrendsCBT.ps1 PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Get-CBT Name PowerState CbtEnabled ---- ---------- ---------- test01 PoweredOn True test02 PoweredOn True PowerCLI C:\Unitrends\unitrends-scripts> Get-VM test0*|Reset-CBT [*] test01 : OK [*] test02 : OK
That is all you need to reset CBT, Get-VM is a PowerCLI command that will get a list of VMs, that list will be passed to our Reset-CBT. So with just command you can reset CBT on a VM, all VMs in a cluster, folder, etc.
Other cmdlets
We have included other cmdlets that are not necessary to reset cbt but you may find useful to check and change CBT status Get-CBT, Get-ChangeId, Enable-CBT, Disable-CBTPowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Disable-CBT [*] test02 : OK Verify CBT Status: PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Get-CBT Name PowerState CbtEnabled ---- ---------- ---------- test01 PoweredOn False test02 PoweredOn False PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Enable-CBT [*] test01 : OK [*] test02 : OK PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Get-CBT Name PowerState CbtEnabled ---- ---------- ---------- test01 PoweredOn True test02 PoweredOn True PowerCLI C:\Unitrends\scripts\CBT> Get-VM test01|Get-ChangeId [*] test01 -> 52 ba 35 cd 98 4e 0c 11-a4 7b f5 02 21 88 4c dd/4 PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Disable-CBT [*] test01 : OK PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Get-ChangeId [*] test01 -> CBT is disabled PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Enable-CBT [*] test01 : OK PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Get-ChangeId [*] test01 -> 52 62 20 74 d6 82 b1 67-a5 55 69 60 da 9a 79 a2/4