I'm working on a small script that will get all the snapshots in a VM and remove all snapshots in the VM except for the 6 newest snapshots, based off the description.
Right now my code looks like this:
get-snapshot -vm "test" | sort -property description | remove-snapshot ?
I am using get-date to make the description for each VM be the date on which it was created, and want to remove all but the 6 newest snapshots. What am I missing with my script to accomplish this task?
I was thinking of using the -getchildren however I'm unable to figure out how to get it to where it would delete snapshots 7 and on.