My last post got me thinking… I myself have a rule-of-thumb that all snapshots will be removed in my environment if they are older than 6 weeks.
I used to do this manually with the SCVMM console… but I dislike manual labor
So, I did some playing around in my latest favorite tool: PrimalScript
This is what I came up with:
Get-VMCheckpoint | ForEach-Object {if ($_.AddedTime -lt (Get-Date).AddDays(-42)) {Remove-VMCheckpoint -VMCheckpoint $_}}
As you can see, I am using the AddDays method. Why I did not use the AddWeeks method?
Simple answer: It doesn’t exsist (yet)
http://technet.microsoft.com/en-us/library/ee176845.aspx
Hi Jeff, is it also possible to “remove old snapshots” without the scvmm?
Hi Atouba5,
Sure that’s possible. When using Windows 8 you can use the native Hyper-V PowerShell cmdlets, but if you’re running an earlier version you can either download the Hyper-V PowerShell module from CodePlex, created by James O’Neill. And if neither of those is an option for you, using WMI and the native buildin PowerShell modules Windows 7 / Server 2008 R2 can do the trick. Read the following post by Ben Armstrong for more information on the later: http://blogs.msdn.com/b/virtual_pc_guy/archive/2011/10/20/deleting-a-snapshot-via-powershell-hyper-v.aspx