SolvedPrivate

PowerCLI script to workaround VMWare bug with CBT

Posted on 2014-11-10
7
16 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 70

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 70

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 70

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 70

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
veeam restore 10 75
Powershell - Set-Location using a variable 2 31
Add incrementing numbers to log file in powershell 1 20
Create a VM Template 17 37
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Teach the user how to convert virtaul disk file formats and how to rename virtual machine files on datastores. Open vSphere Web Client: Review VM disk settings: Migrate VM to new datastore with a thick provisioned (lazy zeroed) disk format: Rename a…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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