Monday, May 25, 2015

Enable or disable CBT

Implementing a new client solution recently based on vSphere 6, there was a request from our backup team to enable CBT on the VMs that were to be backed up. This basically meant around about 160 VMs from the overall solution.

Per the VMware KB article, this would entail shutting down the VM, adding the ctkEnabled parameter and then set its value to true and then Add Row, add scsi0:0.ctkEnabled, and set its value to true. Finally, power the VM back on.

To disable, again, power down the VMs.

This is a bit tedious obviously for 160 VMs, not to mention the downtime incurred for the client solution. However, in the KB article is some PowerCLI script to achieve the same end result, but without powering down the VM.

So, for ease, I took this and just put it into a simple loop to read in the list of VMs from a .txt file (1 VM per line) and make the change. It’s easy enough to have another script to disable the change and do it enmasse. Even better given the (now apparently resolved via latest patch) issue described here.

Also, there’s a one line to list out whether CBT is enabled on all the VMs in the environment.

EnableCBT.ps1

# Enable CBT on number of VMs based on .txt file
# 1 VM per line - name as per vSphere client
# Based on the code from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1031873

$vmlist = Read-Host "Enter the name of the file with the list of VMs"

$vmname = get-content $vmlist

ForEach ($vm in (Get-VM $vmname))
{

    $vmtest = Get-vm $vm| get-view
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    # enable ctk
    $vmConfigSpec.changeTrackingEnabled = $true
    $vmtest.reconfigVM($vmConfigSpec)
    $snap=New-Snapshot $vm -Name "Enable CBT"
    $snap | Remove-Snapshot -confirm:$false

}

DisableCBT.ps1

# Disable CBT on number of VMs based on .txt file
# 1 VM per line - name as per vSphere client
# Based on the code from http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1031873

$vmlist = Read-Host "Enter the name of the file with the list of VMs"

$vmname = get-content $vmlist

ForEach ($vm in (Get-VM $vmname))
{

    $vmtest = Get-vm $vm| get-view
    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    #disable ctk
    $vmConfigSpec.changeTrackingEnabled = $false
    $vmtest.reconfigVM($vmConfigSpec)
    $snap=New-Snapshot $vm -Name "Disable CBT"
    $snap | Remove-Snapshot -confirm:$false

}

CheckCBT.ps1

# Check CBT status on all VMs
get-vm  | Get-View | Sort Name| Select Name, @{N="CBT State";E={$_.Config.ChangeTrackingEnabled}} | ft -AutoSize
  1. best essay writing service

    Monday, September 18, 2017 - 13:40:41

    Well-mannered post. I like your write work manner and language. I am a beginner in writing. I believe this will help me to write better. I exposed these blog articles are superior to other blogs. Thank you such an immense quantity for distribution this resources.

  2. Imargyfammoge

    Monday, September 25, 2017 - 22:29:45

    http://fjdhgksf76w444.com hi everyone

  3. Imargyfammoge

    Friday, October 6, 2017 - 16:23:41

    http://inlottos24.ru

  4. Imargyfammoge

    Friday, October 6, 2017 - 19:03:23

    http://in100slots.ru

  5. Imargyfammoge

    Friday, October 6, 2017 - 20:16:16

    http://maxxybets24.ru

  6. Imargyfammoge

    Friday, October 6, 2017 - 23:06:57

    http://maxprofitslots.ru

  7. Imargyfammoge

    Saturday, October 7, 2017 - 00:19:22

    http://rollslots24.ru

  8. Imargyfammoge

    Saturday, October 7, 2017 - 01:32:49

    http://rollsonline24.ru

  9. Imargyfammoge

    Saturday, October 7, 2017 - 02:46:28

    http://rollslotz24.ru

  10. Imargyfammoge

    Saturday, October 7, 2017 - 16:38:24

    http://joybetsonline.ru

  11. Imargyfammoge

    Wednesday, October 11, 2017 - 04:04:40

    http://joygamingz.ru

  12. Imargyfammoge

    Wednesday, October 11, 2017 - 07:59:48

    http://bingomainia24.ru

  13. Imargyfammoge

    Wednesday, October 11, 2017 - 10:50:36

    http://bingobets24.ru

  14. Imargyfammoge

    Wednesday, October 11, 2017 - 12:20:18

    http://bingomachine24.ru

Add comment

Fill out the form below to add your own comments