Delete multiple NetApp HCI / Solidfire volume snapshots with PowerShell

If you ever need to delete multiple volume snapshots from a NetApp HCI / Solidfire storage array, you will quickly realize there isn’t an efficient way of doing this using the UI – unfortunately you can’t delete multiple snapshots at the same time and each delete request requires a confirmation. Plus if you have a lot of volume snapshots, you will need to search for the snapshot you want to delete every time.

Using PowerShell simplifies the whole process.

First generate a snapshot report using following script.

connect-sfcluster CLUSTER IP

Get-SFSnapshot | select Name, SnapshotID, CreateTime, ExpirationTime, VolumeID, VolumeName | Export-Csv c:\temp\all-snapshots.csv

Sort the resulting CSV file (all-snapshots.csv) by VolumeName then by CreateTime – and highlight the rows including snapshots you want to delete. Then remove all the other rows. Finally remove all columns except the SnapshotID column and save as a new CSV (snapshots-to-delete.csv).

Now run the following script pointing at the new CSV file to delete the snapshots in one go.

$oldsnaps = (Import-Csv 'c:\temp\snapshots-to-delete.csv').SnapshotID

foreach ($snap in $oldsnaps){

Remove-SFSnapshot -SnapshotID $snap -Confirm:$False

}

For more info on how to install the SolidFire PowerShell module and other programmatic approaches to managing NetApp HCI storage – visit my other blog post.

One thought on “Delete multiple NetApp HCI / Solidfire volume snapshots with PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.