SolvedPrivate

PowerCLI script to workaround VMWare bug with CBT

Posted on 2014-11-10
7
11 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 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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
Comment Utility
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 68

Assisted Solution

by:Qlemo
Qlemo earned 500 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:jpletcher1
Comment Utility
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 68

Expert Comment

by:Qlemo
Comment Utility
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
Comment Utility
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 68

Expert Comment

by:Qlemo
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will help you understand what HashTables are and how to use them in PowerShell.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Teach the user how to use configure the vCenter Server storage filters Open vSphere Web Client:  Navigate to vCenter Server Advanced Settings: Add the four vCenter Server storage filters: Review the advanced settings: Modify the values of the four v…
Teach the user how to use create log bundles for vCenter Server or ESXi hosts Open vSphere Web Client: Generate vCenter Server and ESXi host log bundle:  Open vCenter Server Appliance Web Management interface and generate log bundle: Open vCenter Se…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now