List all Snapshots and Export to CSV (7-Mode)

Inspired by this post written by Yann Bizeul (@ybontap), I decided to provide an example of the NetApp PowerShell Toolkit command required to get the equivalent output.

The goal of Yann’s exercise was to gather a list of snapshots and format them in a way that was easy to cut and paste into an Excel spreadsheet.

First a look at Yann’s shell command:


ssh root@10.78.3.1 snap list -n|tr -d '\r' | sed -n -E '{/^Volume /{N;N;N;s/\n/ /g;s/.*Volume ([^ ]*).*/\1/;h;};/^---/,/^$/{/^---/d;/^$/d;G;s/(.*) (..:..)  (.*)\n(.*)/\4      \1      \2      \3/g;p;};}'

The NetApp PowerShell equivalent exported to a CSV file:


PS C:\Scripts> Connect-NaController netapp01; Get-NaVol | Get-NaSnapshot | Select-Object TargetName,Created,Name | Export-CSV -Path outfile.csv

Yann’s command works great and is very useful if you have access to a *nix shell and you are proficient in sed. However, I think it is clear how much effort could be saved by taking advantage of the NetApp PowerShell Toolkit.

Finally, I would like to thank Yann for his imformative post and I encourage you to check out his blog for more great NetApp info: YB Ontap

2 Comments

  1. ybontap says:

    Nice work. I wish we had something like PowerShell on the Mac, it brings great value to scripting in general.
    Perl is more “universal” but nothing beats the PowerShell modular architecture

  2. seanluce says:

    Thank you, Yann! There is always VMware Fusion if you need to get your PoSh fix ;)

Leave a Reply

You must be logged in to post a comment.