VMware Cloud Community
Vimal348
Enthusiast
Enthusiast
Jump to solution

Delete Snapshots

Hello,

We have so many snapshots for multiple VMs that has the snapshot name: 'AAA_SNAPSHOT DDD.CCC.GGG.com 4572373973'.

But the last part (4572373973) is different for all the VMs.

Is there a way we can delete those snapshots for all the VMs by selecting only this first part in the below script : 'AAA_SNAPSHOT DDD.CCC.GGG.com'

I got the below script from LucD​ for deleting the snapshots.

$vmlist = Get-Content "C:\VM\Snapshots\vmlists.txt"

foreach($VM in $VMlist) {

    Get-Snapshot -VM $vm -Name 'Prior to install VM Hardware' |

    Remove-Snapshot -Confirm:$false

}

Disconnect-VIServer -Confirm:$false

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$vmlist = Get-Content "C:\VM\Snapshots\vmlists.txt"

foreach($VM in $VMlist) {

    Get-Snapshot -VM $vm -Name "AAA_SNAPSHOT DDD.CCC.GGG.com*" |

    Remove-Snapshot -Confirm:$false

}


Disconnect-VIServer -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$vmlist = Get-Content "C:\VM\Snapshots\vmlists.txt"

foreach($VM in $VMlist) {

    Get-Snapshot -VM $vm -Name "AAA_SNAPSHOT DDD.CCC.GGG.com*" |

    Remove-Snapshot -Confirm:$false

}


Disconnect-VIServer -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Vimal348
Enthusiast
Enthusiast
Jump to solution

Thank you very much!

0 Kudos