Scope

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.

Pre-requisites

You will need:

  • PowerShell 2.0 or higher installed on your Windows system (Windows 7/Server 2008 R2 has PowerShell 2.0 installed out of the box)
  • The NetApp PowerShell Toolkit DataONTAP.zip file

Install the NetApp PowerShell Toolkit and adding the modules

Extract the downloaded DataONTAP.zip to:

%SYSTEMROOT%\system32\WindowsPowerShell\v1.0\Modules\

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<br />

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 -Credential
</span> </p> 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:
1. Runs the Get-NaShelf command
2. 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.
3. Selects only the headers ID, Status and Name.
4. and then outputs the results into a formatted Table.
list shelves - powershell 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:

set-naoption cifs.smb2.enable on ; set-naoption cifs.smb2.client.enable on ; set-naoption cifs.tcp_window_size 64240 ; set-naoption cifs.oplocks.enable on


This command:
1. Runs many set-naoption commands on a single line (separate by semi-colon “;”).
2. 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 steps
As 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:

Get-Help
</span> </p> In my next blog, I’ll take a look at how you can authenticate and connect to many NetApp controllers and run commands against them all: Connecting to multiple storage systems with the NetApp PowerShell Toolkit