Wednesday, June 9, 2010

Listing NetApp Snapshots using PowerShell

NetApp has recently released a support PowerShell module for managing Data OnTap.

You need to unzip and import the module
import-module DataOnTap

I'm just getting started with it, but I've noticed a few inconveniences. One of the first tasks I would like to do is list all snapshots older than a certain date.
get-navol myvolname | get-nasnapshot

will return a list of snapshots on a given volume, but unfortunately the time is stored as an integer. A little playing around discovered this will provide the correct information:

Get-NaVol myvolume | Get-NaSnapshot | select Name, @{Name="AccessTime"; Expression = {([datetime]"1/1/1970").AddSeconds($_.AccessTime).ToLocalTime()}}

It is possible to find snapshots older than one week using a command like:
Get-NaVol | Get-NaSnapshot | select Name, @{Name="AccessTime"; Expression = {([datetime]"1/1/1970").AddSeconds($_.AccessTime).ToLocalTime()}} | where-object {$_.AccessTime -lt (Get-Date).AddDays(-7)}

Hopefully version two of the module will use native data types to make this all easier.

No comments:

Post a Comment