Last active
January 29, 2018 18:30
-
-
Save Dapacruz/e2cc47a8e3645ffbf07780bb9ba003a6 to your computer and use it in GitHub Desktop.
Enable/Disable Changed Block Tracking (CBT) on VMware Virtual Machines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable CBT on virtual machines | |
$vms = (Get-VM | Get-View).Where{$_.ChangeTrackingEnabled -match 'True'}.Name | |
foreach ($vm in $vms) { | |
$vm_view = Get-vm $vm | get-view | |
$vm_config_spec = New-Object VMware.Vim.VirtualMachineConfigSpec | |
$vm_config_spec.changeTrackingEnabled = $false | |
$vm_view.reconfigVM($vm_config_spec) | |
$snap = New-Snapshot (Get-VM $vm) -Name "Disable CBT" | |
$snap | Remove-Snapshot -confirm:$false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable CBT on virtual machines | |
$vms = (Get-VM | Get-View).Where{$_.ChangeTrackingEnabled -notmatch 'True'}.Name | |
foreach ($vm in $vms) { | |
$vm_view = Get-vm $vm | get-view | |
$vm_config_spec = New-Object VMware.Vim.VirtualMachineConfigSpec | |
$vm_config_spec.changeTrackingEnabled = $true | |
$vm_view.reconfigVM($vm_config_spec) | |
$snap = New-Snapshot (Get-VM $vm) -Name "Enable CBT" | |
$snap | Remove-Snapshot -confirm:$false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get virtual machine changed block tracking status | |
Get-VM | Get-View | select Name, @{n='ChangeTrackingEnabled'; e={$_.Config.ChangeTrackingEnabled}} | | |
sort ChangeTrackingEnabled, Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment