Scheduled task to run a PowerCLI script (and delete a named snapshot)Posted: August 3, 2012 Filed under: PowerShell / PowerCLI, VMware, Windows | Tags: delete snapshot, powercli, scheduled, scheduled task, script, snapshot 1 Comment
I had occasion recently to delete a snapshot at a certain time. It’s easy enough to schedule the snapshot using the vSphere Client and built-in functions, but then, how to delete it on a schedule? Enter PowerCLI and the Windows Task Scheduler.
There was a VMTN forum post by Duncan Epping (@DuncanYB) that suggested using the generic form Get-VM | Get-Snapshot | Remove-Snapshot. This worked a charm for me and I put it into the following script.