Here is a script that will iterate through vCenter and remove all the SnapProtect snapshots - one snapshot at a time.
$vcenter = Read-Host "vCenter Server" $vcuser = Read-Host "Username" $vcpass = Read-Host "Password" -AsSecureString:$true $vccred = New-Object System.Management.Automation.PSCredential -ArgumentList $vcuser,$vcpass Connect-VIServer -server $vcenter -Credential $vccred foreach ($vm in get-vm | sort Name) { $vmname = $vm.name $snaps = get-snapshot -vm $vm foreach ($snap in $snaps) { $snapName = $snap.name if ($snapname -like "__GX_BACKUP__") { Write-Host "Found snapshot: $snapname on $vmname" -foregroundcolor red remove-snapshot -snapshot $snap -confirm:$false } Else { Write-Host "No snapshots found on $vmname" -foregroundcolor green } } }
Here is a modified version, which will remove all snaps - not just ones from SnapProtect.
$vcenter = Read-Host "vCenter Server" $vcuser = Read-Host "Username" $vcpass = Read-Host "Password" -AsSecureString:$true $vccred = New-Object System.Management.Automation.PSCredential -ArgumentList $vcuser,$vcpass Connect-VIServer -server $vcenter -Credential $vccred foreach ($vm in get-vm | sort Name) { $vmname = $vm.name $snaps = get-snapshot -vm $vm foreach ($snap in $snaps) { remove-snapshot -snapshot $snap -confirm:$false } }
Thank you, helped me a lot
ReplyDelete