Hi All,
Snapshots are getting deleted one by one when I am executing below Command.
I need to delete all snapshots for specific VMs on a specific Period of time so I would like to schedule the same.
Get-VM VM1 | Remove-Snapshot
Is there any way to delete all Snapshot at a time as we have option in vSphere Client.
Sort the snapshots on the Created property, the take the oldest one.
Something like this
Get-VM -Name MyVM | Get-Snapshot | Sort-Object -Property Created | Select -First 1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Select the 1st snapshot in the tree and then add the RemoveChildren switch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Alternatively you can try using the below cmdlet which also can delete all snapshots of a VM.
Get-VM VM | Get-Snapshot | Remove-Snapshot -Confirm:$false
Hi Lucd,
Snapshot name will be unique for each VM, Is there any way to select 1st snapshot.
I have tried below that that doesn't work.
Get-VM VM1 | Remove-snapshot -snapshot * -RemoveChildren -confirm:$false
But getting error that * system.string conversion is not possible.
Hi Prakash,
I have tried your command but still snapshot is getting deleted one by one.
Thanks
Sort the snapshots on the Created property, the take the oldest one.
Something like this
Get-VM -Name MyVM | Get-Snapshot | Sort-Object -Property Created | Select -First 1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That works fine. Below is the full command which I have used.
Get-VM -Name VM1| Get-Snapshot | Sort-Object -Property Created | Select -First 1 | Remove-Snapshot -RemoveChildren -Confirm:$false
Thank you so much Lucd.