Vimal348
Enthusiast
Enthusiast

Delete Snapshots

Jump to solution

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

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

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
Vimal348
Enthusiast
Enthusiast

Thank you very much!

0 Kudos