CBT Reset Script

PowerShell script exchange

CBT Reset Script

Veeam Logoby MOBO » Fri Feb 19, 2016 8:27 am

Hi
i have been working on a script to run thru our vCenter and do CBT reset on all VMs when i upgrade to v9
my single server tests have been successful, so i pretty sure it should work,but i thought i would ask if anyone see major downsides/risks to do it with powerCLI or had the same idea before ?

Code: Select all
Add-PSSnapin VMware.VimAutomation.Core
$VMServer = "vCenter.domain.local"
Connect-VIServer -server $VMServer -User Default-User -Password Default-Password

$vms= Get-VM
foreach ($vm in $vms){
$snapshots = Get-Snapshot $vm
if($snapshots -notlike ""){
Write-Output "Remove Snapshot "$snapshots.Name
Get-Snapshot $vm | Remove-Snapshot -confirm:$false
}
$vmtest = Get-vm $vm| get-view
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
#disable ctk
$vmConfigSpec.changeTrackingEnabled = $false
$vmtest.reconfigVM($vmConfigSpec)
Start-Sleep -s 10
$snap=New-Snapshot $vm -Name "Disable CBT"
Start-Sleep -s 10
$snap | Remove-Snapshot -confirm:$false
Write-Output "Disable CBT on"$vm
# enable ctk
$vmConfigSpec.changeTrackingEnabled = $true
$vmtest.reconfigVM($vmConfigSpec)
Start-Sleep -s 10
$snap=New-Snapshot $vm -Name "Enable CBT"
Start-Sleep -s 10
$snap | Remove-Snapshot -confirm:$false
Write-Output "Enable CBT on"$vm
}
MOBO
Influencer
 
Posts: 11
Liked: 2 times
Joined: Sat Jan 24, 2015 7:26 am
Full Name: Morten Boegeskov

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests