Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
SolvedPrivate

PowerCLI script to workaround VMWare bug with CBT

Posted on 2014-11-10
7
Medium Priority
?
18 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 71

Accepted Solution

by:
Qlemo earned 2000 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 71

Assisted Solution

by:Qlemo
Qlemo earned 2000 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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 71

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 71

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Teach the user how to install and configure the vCenter Orchestrator virtual appliance Open vSphere Web Client: Deploy vCenter Orchestrator virtual appliance OVA file: Verify vCenter Orchestrator virtual appliance boots successfully: Connect to the …
This Micro Tutorial steps you through the configuration steps to configure your ESXi host Management Network settings and test the management network, ensure the host is recognized by the DNS Server, configure a new password, and the troubleshooting…

730 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