The Data ONTAP PowerShell Toolkit
The Data ONTAP® PowerShell Toolkit forum on the NetApp Community pages has seen a lot of activity since the toolkit was released in June 2010. Because of the high level of interest, Tech OnTap asked John Fullbright of NetApp Professional Services to explain the toolkit for Tech OnTap readers.
In a busy storage environment, there are dozens of tasks to be performed every day. Wouldn’t it be great if you had an easy way to automate repetitive tasks?
That’s exactly what the Data ONTAP PowerShell Toolkit does for those working in Microsoft® environments. For example, in large-scale virtualized environments, it can be difficult to map all the LUNs used by various virtual machines. One toolkit user, Erick Moore, used the toolkit cmdlets and Visio to create a script with graphical output that maps LUNs to VMs. An example of the output is shown in Figure 1.
Figure 1) Output from a PowerShell script that uses the Data ONTAP PowerShell Toolkit and Visio to map VMs to storage LUNs.
This is a pretty dramatic example of what the toolkit can accomplish, but you’ll be amazed at how much you can accomplish with just a few lines.
In this article, I explain what the Data ONTAP PowerShell Toolkit is, talk about some common use cases, give some tips on developing your own scripts, and provide some pointers to useful resources.
What Is the Data ONTAP PowerShell Toolkit?
Windows® PowerShell is Microsoft’s command-line shell and scripting language for system administrators. In PowerShell, administrative tasks are performed by specialized cmdlets (pronounced command-lets).
The Data ONTAP PowerShell Toolkit is a NetApp developed set of cmdlets for Windows PowerShell that encapsulate many of the APIs available in the NetApp Manage ONTAP® Software Developer’s Kit. These cmdlets let you tap into the power of NetApp APIs to easily perform a wide variety of NetApp specific tasks from within PowerShell scripts. Over 400 cmdlets are available, covering all aspects of NetApp operation.
You can download the toolkit here (free to Data ONTAP customers and partners).
Common Use Cases
Possible use cases for the Data ONTAP PowerShell Toolkit are almost endless. I’ll mention a few of the ideas that have been developed and posted on the NetApp Community forum that I think are of particular interest. A later section has links to resources you can access for more information on these and other use cases.
Automated Provisioning. Provisioning new storage is often a time-consuming task. Using the toolkit you can create scripts that let you connect to a storage system, create aggregates and volumes within those aggregates, and set the appropriate options on each volume.
Monitoring and Managing Snapshot Copies. A common task is to go through all your NetApp storage to see how many Snapshot® copies you’ve got and how much space each is retaining. Another Snapshot-related task is to periodically remove older Snapshot copies based on time or the number of Snapshot copies you want to keep. PowerShell toolkit scripts can do this work for you.
Thin Provisioning. Thin provisioning can save you a lot of storage capacity. Before you use it, however, you’ll want to know how much space you can potentially save, and then you’ll want an easy way to enable the thin-provisioning settings on each volume. The forum includes scripts that can help you do both. (You can learn more about thin provisioning in a companion article in this issue of Tech OnTap.)
Mirroring. The Data ONTAP PowerShell Toolkit includes a number of cmdlets to manage NetApp SnapMirror®, including the ability to create mirrors, initiate updates, and break and reverse relationships. Using the available capabilities, you can automate almost any SnapMirror operation.
Tips for Developing Scripts
Windows PowerShell uses pipelined execution similar to bash for simplified scripting. If you’re not already familiar with PowerShell, the first thing you want to do is familiarize yourself with it. A variety of Web resources exist, such as Windows PowerShell Basics on the Microsoft TechNet Web site.
Once you’ve got the basics down, you’ll want to learn about the capabilities of the NetApp specific cmdlets in the Data ONTAP PowerShell Toolkit. You can see the list of cmdlets by entering the following at the PowerShell command prompt (with the toolkit installed):
Full details can be viewed by entering:
You can get help on a specific cmdlet by entering either of the following:
The help file for each NetApp cmdlet includes at least one real-usage example.
When the Data ONTAP PowerShell Toolkit was launched, I posted a lot of “how to” information on various NetApp topics on the Toolkit forum. If you go to the main forum page and search on “HOWTO” or “fjohn” you’ll easily locate these posts.
The great thing about PowerShell scripts—including those that use the Data ONTAP toolkit—is that you almost never have to start writing from scratch. You almost always can find an existing script to use as a starting point. The following section links to a few resources to help you get started.
Got opinions about Data ONTAP PowerShell Toolkit?
Ask questions, exchange ideas, and share your thoughts online in NetApp Communities.