SolvedPrivate

PowerCLI script to workaround VMWare bug with CBT

Posted on 2014-11-10
7
15 Views
Last Modified: 2016-02-25
Our backup software vendor, VEEAM, has published a PowerCLI script as a workaround for the VMWare CBT bug.  This is it below.  I want to be able to do this one VM at a time.  How would I accomplish this below but change it for one specified VM?

Get the VMs with CBT enabled:
$vms=get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}

Create a VM Specification to apply with the desired setting:
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.ChangeTrackingEnabled = $false

Apply the specification to each VM, then create and remove a snapshot:
foreach($vm in $vms){
$vm.ExtensionData.ReconfigVM($spec)
$snap=$vm | New-Snapshot -Name 'Disable CBT'
$snap | Remove-Snapshot -confirm:$false}

Check for success:
get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}
0
Comment
Question by:jpletcher1
  • 4
  • 3
7 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40433030
One way, if you do not want to be specific about the VM to work on, is to just take out the first VM found:
# Get only first VM with CBT enabled
$vms=get-vm | ? { $_.ExtensionData.Config.ChangeTrackingEnabled } | select -first 1

Open in new window

Each time you run the script, it will only process a single VM.
There are a lot of other ways we can imagine, like showing all found VMs and allow for choosing one.
0
 

Author Comment

by:jpletcher1
ID: 40433039
Thanks, but I would like to be able to specify the name of the VM.  Could I do a where name is equal to or something like that?  I don't know the actual syntax.
0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 500 total points
ID: 40433055
Use Get-VM -Name ThisIsMyVM to get a specific VM. You can use an asterisk so you do not need to write the name out completely.
In the code it would look like this:
$vms = Get-VM -Name ThisIsMyVM | ? { $_.ExtensionData.Config.ChangeTrackingEnabled }

Open in new window

0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:jpletcher1
ID: 40433172
So can run all these lines together in a script like this for example for "Server1" ?


 $vms=get-vm -name Server1 | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}
 $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
 $spec.ChangeTrackingEnabled = $false
 foreach($vm in $vms){
 $vm.ExtensionData.ReconfigVM($spec)
 $snap=$vm | New-Snapshot -Name 'Disable CBT'
 $snap | Remove-Snapshot -confirm:$false}
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40433224
Correct. If the VM specified has already been processed before, nothing will happen.

But if I read the info for this bug correctly, you should need to do that only once after the 128GB*x size boundary of the VMDK file has been passed, and then re-enable CBT.
0
 

Author Comment

by:jpletcher1
ID: 40433251
Correct, it's a one time thing.  With the new version of VEEAM, if a VM is reconfigured to extend a disk past the 128GB limit, the VEEAM backup software will do this automatically.  But any VMs that were extended previously need to be manually done.

How does the script know if this has already been run on a VM?  I know the script changes CBT to be off, then creates/deletes a snapshot.  Then the VEEAM software re-enabled CBT when it runs.  I'm guessing you were saying this because the script itself leaves CBT disabled, so a re-run would just run and not change anything?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40433266
A rerun without running a VEEAM backup should not perform a change - CBT is off, so no result.
After running VEEAM backup (and CBT switched on), there is no indication you already performed the workaround. But since you do all that manually, you should know yourself which VMs are "ok" ;-).
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Giving access to ESXi shell console is always an issue for IT departments to other Teams, or Projects. We need to find a way so that teams can use ESXTOP for their POCs, or tests without giving them the access to ESXi host shell console with a root …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Teach the user how to delpoy the vCenter Server Appliance and how to configure its network settings Deploy OVF: Open VM console and configure networking:
Teach the user how to join ESXi hosts to Active Directory domains Open vSphere Client: Join ESXi host to AD domain: Verify ESXi computer account in AD: Configure permissions for domain user in ESXi: Test domain user login to ESXi host:

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question