PowerShell

Snapshots are one of the core features of ONTAP, and something that many, many people rely on every day to protect their data from accidental (or malicious…) deletion and corruption. The NetApp PowerShell Toolkit can help us to manage the configuration of snapshot policies, the application of those policies to volumes, and creating/deleting/reverting snapshots too.

There are multiple ways to do authentication to NetApp systems when using the PowerShell Toolkit. This ranges from the simple and obvious one-time connection, to securely storing credentials for future use. Saving credentials can be useful when executing scripts from a host non-interactively, such as with scheduled tasks or triggered through another script.

Connecting to a Single Controller

The Connect-NcController is the standard method of connecting to a clustered Data ONTAP controller. Connect-NaController is the 7-mode equivalent and works identically. Additionally, the same credential rules apply for the Invoke-NcSsh and Invoke-NaSsh cmdlets as well.

Arguably the most common method of connecting to a controller is by simply providing the hostname:

1

2

3

# this will attempt to connect to the specified controller using stored credentials, or if none

# are found, will prompt for credentials. it will also default to HTTPS, with a fallback to HTTP

Connect-NcController$myController

If you are connecting to an SVM’s management interface this will work as expected, though some cmdlets won’t work because of the limited scope. If you want to connect to an SVM by tunneling through the cluster management interface, use the -Vserver parameter.

1

Connect-NcController$clusterMgmtLif-Vserver$SvmName

However, there are a number of parameters which change the default behavior.

There’s one particular part of the NetApp PowerShell Toolkit which is not frequently used, but is extremely powerful. Templates can be created for many of the object types which are used to create a query for specific objects, or for limiting the amount of information returned from a particular cmdlet invocation.

To get started, we first need to initialize the object for our query or attribute limiting template. To do this we use the -Template parameter to our cmdlet.

1

2

# create an empty Aggregate object template

$aggrTemplate=Get-NcAggr-Template

If we were to look at this object it is empty:

Many of the properties associated with an object, such as an aggregate, volume, or LUN, are objects themselves. If we want to use a property of a child object as the query filter then we need to initialize that property in the template object.

In December I had fun solving the “riddles” at Advent Of Code and a large number of them (starting with number 1) had strings for input that needed to be parsed. So, posting this for myself, cause I can never remember it….

Convert a string to an array of single characters

1

2

3

4

5

6

7

8

9

10

# the input string

$string="This is a string"

# convert it to a character array

$array=$string.ToCharArray()

# now we can iterate like any array

foreach($charin$array){

$char

}

The output:

Convert a string into an array of words

1

2

3

4

5

6

7

8

# the input string

$string="This is a string"

# create an array from an arbitrary separator, in this case a space

$array=$string.split(" ")

# this will also work

$array=$string-split" "

Convert a string based on arbitrary characters

This also works with regular expressions…

1

2

3

4

5

6

7

$string="a1b2c3d4e5f6"

# split on numbers - remember, this will remove the numbers from the output

Environmental information, for example temperature, fan speed, etc., provide critical information about the health of your clustered Data ONTAP system. Depending on your version of ONTAP, you can query the environmental information different ways to find out the status.

With ZAPI version 1.21 and above (cDOT 8.2.3+) the environment-sensors-get-iter API exists, which makes it excessively easy to collect environmental information about the controllers. We can take the same approach with environmental sensors as performance information:

Performance monitoring is a complex topic, but it’s something that is vital to the successful implementation and maintenance of any system. In the past I’ve had severalposts about using Perl for gathering performance statistics from a 7-mode system (using ONTAP 7.3.x, which is quite old at this point), so I thought it might be a good time for an update.

I originally documented some of this information in a response on the NetApp Community site. This post expands on that a bit and documents it externally.

The NetApp PowerShell Toolkit has three cmdlets which we can use to determine what objects, counters, and instances are available, and a fourth cmdlet to actually collect the data.

Protecting data is arguably the most important job that your storage is entrusted with. Losing data is simply not an option, so it’s critical to protect data through the use of backups and replication.

There are different ways that you can replicate data in your clustered Data ONTAP system. First, you can replicate to a separate volume of the same SVM in the cluster. Second, to a volume that belongs to a different SVM in the same cluster. Finally, replication can be configured with another cluster entirely.

In this post we will cover:

Peering Relationships

Cluster Peers

SVM Peers

SnapMirror Policies

SnapMirror

Version Flexible SnapMirror

SnapVault

Load Sharing Mirrors

If you are interested in additional detail about SnapMirror and SnapVault in clustered Data ONTAP 8.3, please see the post I did over at DatacenterDude.com.

Over the last several posts we have reviewed how to create and manage aggregates, SVMs, and volumes. All of that is great, but at this point you still can’t access that capacity to begin storing things. In this post we will discuss the various ways to access the volumes and the data inside them.

Volumes are the containers of data in a NetApp storage system. They are “stored” on aggregates, accessed via Storage Virtual Machines, and are the point-of-application for many of the features of Data ONTAP. Let’s look at what we can do with volumes leveraging the PowerShell Toolkit:

Storage Virtual Machines (SVM) are the entity in clustered Data ONTAP which the storage consumer actually interacts with. As the name implies, they are a virtual entity, however they are not a virtual machine like you would expect. There are no CPU, RAM, or other cache assignments that must be made. Instead, we assign storage resources to the SVM, such as aggregates and data LIF(s), which the SVM then uses to provision FlexVols and make them available via the desired protocol.

In this post we will look at how to configure an SVM using PowerShell.