Thursday, September 20, 2012

Netapp Powershell command to find all snapshots older than 28 days

1 Download dataontap PS module and extract to c:\windows\system32\windowspowershell\1.0\modules

2 Import the netapp powershell module
   Import-Module dataontap

3 define $28days as being todays date - 28 days
   $28days = (get-date).adddays(-28)

4 connect to the controller
   connect-nacontroller "controllername"

5 view the list of snapshots that are older than 28 days
   Get-Navol | Get-NaSnapshot | where-object { $_.name -like "smvi_*" -and $_.created -lt $28days }

6 See what snapshots will be deleted
   Get-Navol | Get-NaSnapshot | where-object { $_.name -like "smvi_*" -and $_.created -lt $28days }  | remove-nasnapshot -whatif

7 Delete the snapshots
     Get-Navol | Get-NaSnapshot | where-object { $_.name -like "smvi_*" -and $_.created -lt $28days }  | remove-nasnapsho