Simple Way to Delete all Snapshots on vSphere - PowerCLI
Have our virtualization environment free of snapshots is a best practice to prevent low storage problems and performance degradation.
- Check you environment for snapshots older than 7 day's, using the command:
Get-VM| Get-Snapshot |Where {$_.Created -lt (Get-Date).AddDays(-7)}| Select-Object VM,Name,Created,@{N="SizeGB";E={[math]::round($_.SizeGB, 1)}} | FT
- Delete all snapshots for a specific VM run:
Get-VM MYVM-NAME| Get-Snapshot | Remove-Snapshot -RemoveChildren -Confirm:$False
- If you want delete all snapshots for all VM's use:
Get-VM | Get-Snapshot | Remove-Snapshot -RemoveChildren -Confirm:$False
- Sometimes delete snapshots fail in consolidation process and snapshot manager don't show snapshots. To check if all VM's are OK run:
Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded}
- To start consolitation process execute:
Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} | foreach {$_.ExtensionData.ConsolidateVMDisks_Task()}
https://www.vmware.com/support/developer/PowerCLI/PowerCLI65R1/html/Get-VM.html
https://www.vmware.com/support/developer/PowerCLI/PowerCLI65R1/html/Get-Snapshot.html
https://www.vmware.com/support/developer/PowerCLI/PowerCLI65R1/html/Remove-Snapshot.html
Comentarios