PowerShell script exchange
Post Reply
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak »

Hi All,

In this CBT bug, we all know there is fix from VMware http://kb.vmware.com/kb/2137545, this will fix the problem for the hosts and new VMs, not the VMs that we have. To fix the issue and have a proper backup vs restore we need to reset the CBT, and then Veeam as a PowerCli script that will fix CBT https://www.veeam.com/kb1113. My problem is whit this script.

Don't know if anyone had this problem with this script. But if I use this part in bold $ivms = get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}; i get this error:

Code: Select all

Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Users\edualuc\AppData\Local\Temp\Rar$DIa0.861\MassResetCBT.ps1:56 char:22
+     if ((Get-VM -name <<<<  $vm).PowerState -ne "PoweredOn") {
    + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
And the $ivms is always getting "null". So no VMs in the array to display.

If I just comment the part #?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}; then the script can run and VMs can be displayed. But no check if the VMs has the CBT enable or not.

I have done some change on the script to try to get this to work, but I was never able to put this check to work.

Anyone had the same problem with this script??

I even created a small script just to check the if CBT was enable in a VM, but I get always false results. I think my problem is that I using the wrong object to check the CBT in the VM.

My example:

Code: Select all


$VMCBT = Get-Cluster "Cluster Test" | get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true};

foreach ($VMCBTs in $VMCBT){

if ($VMCBTs | where {$_.ExtensionData.config.ChangeTrackingEnabled -eq $True}){
   Write-Host ($VMCBTs.Name) ' CTB Disable'
 
 } else { Write-Host ($VMCBTs.name)  ' CBT is Enabled'}
 }}
I always get false results where. I have created some test VMs and in some I add the parameter scsi0:0.ctkEnabled = true and also ctkEnabled = true to test if it gives True result in the script, but no.

I need to run the Veeam Script this weekend in 2000+ VMs, and I need have the script running properly.

So anyone had similar issues with this script, or at least know the right object in the VM View to grab the enabled/disable CBT??

Thank You

JailBreak
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak »

Hi

Just an update:

A small change in the script I can now list all disabel and enable CBT VMs, but still not able to transport this into the Veeam Script

Code: Select all

$VMCBT = Get-Cluster "Cluster Test" | get-vm #| ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true};

foreach ($VMCBTs in $VMCBT){

if ($VMCBTs | where {$_.ExtensionData.config.ChangeTrackingEnabled -eq $true}){
 Write-Host ($VMCBTs.Name) ' CTB Enable'

 } else { Write-Host ($VMCBTs.name)  ' CBT is disable'}
 }
Only putting the where condition in the IF and not in the GET-VM

Still need to transport this condition into the Veeam script so that I can bypass the initial problem

Thanks

Jail
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak » 1 person likes this post

Hi All,

Fix the Veeam just using the where condition.

Code: Select all

$ivms = get-vm | where {$_.ExtensionData.config.ChangeTrackingEnabled -eq $true}; 
instead of

Code: Select all

$ivms = get-vm | ?{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true};
With this change all VMs with CBT enabled will be on the list. With the original line, all VMs list is null(at least in my case).

So if anyone had the same issue, this is how I fixed.

Thank You

Jail
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by veremin »

Strange behaviour, indeed, as both question mark and where are aliases for where-object commandlet, and should work exactly the same. Aren't you using default Powershell 2.0 (Windows 2008 (R2)) by any chance? Thanks.
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak »

Hi v.Ermin,

Thank you for your reply.

That is what I tough when I was troubleshooting the problem, both are alias.

I am using this in my laptop and I have:

Code: Select all

> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5485
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

Code: Select all

> get-host

Name             : ConsoleHost
Version          : 2.0
InstanceId       : e45353b7-93fd-4c72-ba1c-95a003b00ac2
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
Is a bug in the 2.0 version?

I am running the script at this moment, but after I will update my PowerShell and also PowerCLI and test again with the original script.

Thank again for your reply.

Jail
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by veremin »

Is a bug in the 2.0 version?
Hard to say for sure. However, while working with PowerShell and our customers using it, we've seen number of strange issues, such as cmdlets misbehaving, properties missing, etc. occurring only in cases when PS 2.0 was used.

So, it might be worth updating PowerShell and seeing whether the issue is reproducible.

Thanks.
Craigb
Influencer
Posts: 15
Liked: 28 times
Joined: Nov 14, 2012 2:28 am
Full Name: Craig Braithwaite
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by Craigb »

PowerCLI semi-colon handling in ResetCBT.ps1 (powershell 3.0 on VC host)
----------------------------------------------------------
VMware is up to date and veeam is updated.
Now fixing CBT so I that I can re-enable use of it in my veeam B&R jobs.
I had powershell warnings and wasn't asked to provide name/ip of my VC until I removed the semicolons from lines 40, 46, 47, 50 and 53 of the ResetCBT.ps1 script.
I also removed the semicolons from lines 42 and 54..58 but as I missed the one on line 42 in my test I suspect that these don't matter. Something to do with ending a command, and ending a command but followed by a comment.

In general:
I didn't investigate more than that but if you have red PS warnings after you "press any key" indicating you understand the warning when you run ResetCBT.ps1, remove the semi-colons and you'll be ok.

for the OP:
The reason for this "Cannot validate argument on parameter 'Name'. The argument is null or empty." could be that the ivms variable was never populated. I removed the semi's before getting that far, but if it didn't read-host on line 46, then it probably didn't populate ivms on line 47 for the same reason.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by veremin » 1 person likes this post

PowerShell considers semi-colon as statement separator. In other words semi-colon separates one logical command from the other.

As far as I can tell, the provided example should work with or without semi-colons, as the usage of those doesn't seem to affect the script logic anyhow.

Thanks.
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak »

v.Eremin wrote: Hard to say for sure. However, while working with PowerShell and our customers using it, we've seen number of strange issues, such as cmdlets misbehaving, properties missing, etc. occurring only in cases when PS 2.0 was used.

So, it might be worth updating PowerShell and seeing whether the issue is reproducible.

Thanks.
Sorry my late reply, just to update that with 2.0 I did not get this issue.

Thanks

JailBreak
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by veremin »

Sorry my late reply, just to update that with 2.0 I did not get this issue.
I'm slightly confused, as previously you've reported the issue while working with PS 2.0. Thanks.
JailBreak
Veeam Vanguard
Posts: 35
Liked: 9 times
Joined: Jan 01, 2006 1:01 am
Full Name: Luciano Patrao
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by JailBreak »

Sorry v.Eremin fixed with 3.0, not 2.0. With 2.0 I had the issue.

Thank You
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: ESxi 6.0 CBT bug - Veeam script to reset CBT

Post by veremin »

That's what I suspected. Another strange issue related to Powershell 2.0 that has been solved by updating to newer versions. Anyway, glad to hear that you don't have those problems any longer. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests