Getting Started with the NetApp PowerShell Toolkit

This post takes a quick look at the NetApp PowerShell Toolkit: a set of PowerShell cmdlets which can be used to query and change settings on NetApp Storage Systems, paving the way for automation of common tasks or generating regular reports. It runs through installing the PowerShell toolkit, and running a few basic commands against a NetApp storage system.

Resources

The following resources will be of use. You’ll need a NetApp “NOW” account to download things. It’s free to sign up, but according to NetApp you’ll need to be a customer or a partner to download the Toolkit.

The files should end up inside: %SYSTEMROOT%\system32\WindowsPowerShell\v1.0\Modules\DataONTAP

Note: On a multi-user system, if you want the toolkit to be available for only yourself, place it inside: %USERPROFILE%\Documents\WindowsPowerShell\Modules\

Start PowerShell and run:

import-module DATAONTAP

Optional: Add the import-module DataONTAP command to your profile (so it’s available every time you use PowerShell):

Where is our profile?:

$profile

Does that profile exist?:

test-path $profile

If True, skip the “If False” step and move to notepad $profile.

If False, run:

new-item $profile -itemtype file -force

Edit the file:

notepad $profile

Add the following line to the ps1 file:

import-module DataONTAP

Save the file. You’ll now import the DataONTAP PowerShell modules every time you start PowerShell!

Getting help

One of the most important functions in PowerShell – or any command-line shell – is the ability to get help. You’ll find this invaluable as you work your way around PowerShell and the NetApp toolkit (I certainly have!).

To view the list of cmdlets available from the NetApp toolkit:

Get-NaHelp

Use -Category switch and/or wildcards to narrow the results. For example:

Get-NaHelp -Category volume

Get-NaHelp -Category options

Get-NaHelp *NaCredential

To see help for a specific cmdlet (command):

Get-Help Connect-NaController

For full details of a cmdlet, including examples:

Get-Help Connect-NaController -full

Authenticating and connecting to a NetApp storage system

Before you can run commands/queries against a storage system, you need to connect to it and authenticate to it.

Add login credentials for the session

The Add-NaCredential cmdlet caches credentials for a storage system. This can be useful if you manage many storage systems, potentially each with different credentials. When you come to connect to a storage system using Connect-NaController, the connection will authenticate with the information held in the auth cache (pretty neat!).

Add-NaCredential -Name <hostname> -Credential <username>

For example:

Add-NaCredential -Name cylon82 -Credential root

Alternatively, just use -Credential with the Connect-NAController command, if using a single NetApp controller

To see current credential list:

Get-NaCredential

For example:

Connecting to a single NetApp controller

Now you can open a connection to a Netapp controller to run some commands against it.

Connect-NaController -Name cylon82

Or if you didn’t specify authentication credentials earlier, try:

Connect-NaController -Name cylon82 -Credential root

For example:

Basic usage

To get started, let’s take a look at a few very basic commands.

Get System Information from the NetApp controller you’ve connected to

OK, now you’re connected, run a few sample commands to get a feel for how this works.

Let’s look at some basic system information:

get-nasystemversion

get-nasysteminfo

Volume information

Alright, now let’s take a look at the volumes on the system.

Get-NaVol

It’s also possible to roll up two commands to run one after the other, using the semi-colon separator “;”, for example:

Get-NaVolContainer ; Get-NaVol | format-table

It’s powerful, too!With the power of PowerShell, we can do some really neat things. Take these two for example:

How many shelves are connected to my system?*This only works on a real NetApp storage system. It won’t work on a NetApp Simulator, sorry.

Normal command:

Get-NaShelf

Advanced:

Get-NaShelf | Sort ID -Unique | Select ID,Status,Name | Format-Table

This advanced command:

Runs the Get-NaShelf command

Sorts the output by Column ID (so they’re in order) and removes duplicates from the column. This is useful as Get-NaShelf outputs details for both channels of a shelf ID if you’re using Multipath cabling.

Selects only the headers ID, Status and Name.

and then outputs the results into a formatted Table.

Setting many options in one go

As above, it’s possible to run a number of commands on a single line. In the example below, I’m setting some CIFS/SMB options on a test storage system:

Runs many set-naoption commands on a single line (separate by semi-colon “;”).

This makes it easier to see what’s been run on the filer after the commands complete, as they all appear in a single block

How was that?

How did you find that?

I was amazed at how easy it is to pick up and play with, given an hour or so initially. I really like the potential of the toolkit for automation some of my SMB benchmarking tasks, so I’ll be looking at that over the next few weeks.

As always, I encourage and welcome feedback. So drop me a note in the comments! 🙂

Next stepsAs you can see, the toolkit is very powerful; and I’ve barely scratched the surface! Take a look at all the options available to you by running:

Get-NaHelp

And for each interesting option, you can get more information by running: