- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have created snapshots for many VMs with the description:"Prior to install VM Hardware"
Can someone please tell me how to remove those snapshots that has a description : "Prior to install VM Hardware"
$vmlist = Get-Content "C:\VM\Snapshots\vmlists.txt"
foreach($VM in $VMlist) {
Get-Snapshot -VM $vm |
Remove-Snapshot -Confirm:$false
}
Disconnect-VIServer -Confirm:$false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try like this
foreach($VM in $VMlist) {
Get-Snapshot -VM $vm -Name 'Prior to install VM Hardware' |
Remove-Snapshot -Confirm:$false
}
Disconnect-VIServer -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello LucD,
Thank you for your script. Your suggestion works for the snapshot that has the name: 'Prior to install VM Hardware',
Here my snapshot names are different for each VMs, but Description is same : 'Prior to install VM Hardware',
Hence, is it possible to delete the snapshot collecting that Description name: 'Prior to install VM Hardware',
Upload and share screenshots and images - print screen online | Snipboard.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Then you could try like this
foreach($VM in $VMlist) {
Get-Snapshot -VM $vm | where{$_.Description -eq 'Prior to install VM Hardware'} |
Remove-Snapshot -Confirm:$false
}
Disconnect-VIServer -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you LucD
The script works perfectly...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
what is a general script i can use to delete snapshot from my environment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean by "general"?
Remove all snapshots?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Luc,
Quick question please can we remove Snapshot from the listed VMs but based on Date and time of the snap wich should be listed into the CVS file ?
Exemple for the Csv VM Name / Date / Time of Snap Creation /
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The object returned by Get-Snapshot contains a property Created.
You could use a Where-clause to only select the snapshot corresponding with a specific DateTime.
Just be aware that specifying the correct time in your CSV might be inaccurate since a DateTime is very precise (sub-second).
I would approach this with a time interval based on the value in your CSV
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
For me I create a 3 lines script to remove all snapshot older then 3 days, but it looks like the log file not working, I get nothing in the file.
Do you have any suggestion ?
Connect-VIServer -server blablabla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the RunAsync switch the snapshot removal becomes a background task, and hence not producing any output.
You could use Get-Task, wait till all background tasks are completed, and then capture the info in the object returned by Get-Task.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a good thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, could you please share with us the script after the modification. Im intrest in it.
Thanks