Thursday, May 24, 2018

Remove snapshots on vCenter easily

If you have a bunch of snapshots all over your environment and you need to pick only a few to remove, here's an easy way.

I was looking through some posts and found this to get started. http://pipe2text.com/?page_id=251

I modified it a bit to get the items I needed.

We had an issue where the NetApp snap manager process failed and stayed in the event log at 44% or 59%. Rebooting the vCenter server worked, but we were left with smvi_ snapshots all over the place.

$snaps = get-vm svr-00* | get-snapshot | where {$_.descrption -like "*201804*" | select-object vm,name,description | out-gridview -mode multiple
foreach ($snap in $snaps) {
get-vm $snap.vm | get-snapshot $snap.name -RunAsync -verbose -confirm:$false
}

You can change the svr-00* to be a subset of your VMs or remove it to get all of them.
You can modify "*201804*" to filter for a particular description.

Gives you a nice list, you can sort by column, pick the ones you want and clean it up.

If you want to get fancy, you can change the items to variable,s get some input from the user and plop it into the code. But I'll let you get fancy, here is the quick and dirty to get you started.

No comments:

Post a Comment