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.
1 2 3 4 5 6 7 8 |
# create an empty Aggregate object template $aggrTemplate = Get-NcAggr -Template # initialize a property of the template Initialize-NcObjectProperty -Object $aggrTemplate -Name AggrRaidAttributes # alternatively, initialize all properties during template creation $aggrTemplate = Get-NcAggr -Template -Full |
Our template object now has a property object which has been populated:
At this point we’re ready to use the template, let’s look at how to use it as a query or to limit the attributes returned.