I'm going crazy trying to find how to properly use Get-NcVol to retrieve complete information of a single volume. The issue is that some properties are returned as $null and I can't find recent, clear, and dependable guidance anywhere in netapp.com about the right way to use Get-NcVol to retrieve all the attributes / properties I need. Please, help.
#I'm lost with Get-NcVol
1 messages · Page 1 of 1 (latest)
Hi Benaph,
I assume you have already connected to the cluster with connect-nccontroller.
From there you can do something like:
Get-ncvol -name {volname} -vserver {svm name} | fl *
Basically you are piping all the data from the get-ncvol command into the format-list command and stating list all items with the *
If you want to drill down into one of the sub hashes you can do this:
Get-ncvol -name {volname} -vserver {svm name} | select -ExpandProperty VolumeSpaceAttributes
The VolumeSpaceAttributes is from the ...| fl * output. You will see many items with the value of dataontap.c.types.volume........ You can expand any of them.
I hope this helps and is what you are looking for
And another note:
You can save the inital data into a variable like this:
$data = Get-ncvol -name {volname} -vserver {svm name}
Then you can just specifiy the attributes you are looking for in . notation, such as:
$data.VolumeSpaceAttributes.sizetotal 612032839680
That number you get back can be formatted to the units you need, such as
$data.VolumeSpaceAttributes.sizetotal / 1GB 570
Hello, @silk furnace. Thanks for the advice, I appreciate it. Now the doubts I have are related to the right way to use the cmdlet Get-NcVol with options -Template, -Attributes, and -Query, also about the usage of Initialize-NcObjectProperty, since I have dozens of SVMs and hundreds of volumes, I need to make the most efficient and fastest queries. Any ideas?
Hey Benaph, I have never utilized the -template, -attributes, and -query options, and the Initialize-NcObjectProperty. I just looked into it and it is really cool. As with all things in powershell there are a dozen ways to attack the problem that will be successful. In my environment I manage lots of volumes also, and usually make bulk changes. I usually pull all volume data into a variable ($voldata = get-ncvol). From there I iterate through the data to make reports or changes. I try to minimize the number of times I need to pull or push data to the cluster for performance reasons. Sometimes you cannot avoid taking a hit in performance because of the changes involved.
I worked through the example in the help docs, but not much more. I don't have a lot to test on at the moment. Maybe building the template as a hashtable would save some time if you know what params you are seaching for and because it takes one command instead of several. In the help example you are creating an template object and adding values to the fields.
$queryhash = @{name = "vol1|vol2|vol3" vserver = "svm1"}
Then you can pass that to the query, get-ncvol -query $queryhash. Get-ncvol takes the hash the same way it takes the template object since its easy to convert a hashtable to an object.
If your hashtables are really big you might benefit from using .net generic lists. You would really need to experiment. I have re-written some powershell function several times as I figure out better ways to do something. Hope this helps. I might tinker with the help example and see what I find.
Some notes I had lying around regarding Templates and Queries:
In my mind, templates are more like "search criteria" than a template. You first create an empty template to define the type of object you want to search for along with all of its possible attributes.
Then, you define a query to search for a particular attribute with a particular value. I was never able to get the templates to work right, but the queries work nicely as detailed below.
Create an empty aggregate template: $aggrTemplate = Get-NcAggr -Template
View a list of properties of the template: $aggrTemplate | Format-List *
Initialize a single property within the template: Initialize-NcObjectProperty -Object $aggrTemplate -Name Nodes
Define the value to filter for within the property: $aggrTemplate.Nodes = "Nodename-01"
Use the template to query the controller and filter based on the template values : Get-NcAggr -Query $aggrTemplate
Get aggregates with Aggr Space Attributes: Get-NcAggr -Attributes @{AggrSpaceAttributes=@{}}
Query for a particular value without defining a template first: Get-NcVol -Query @{Name="VolumeName"}
Get nested attributes, in this case: all volumes that are not root volumes (vol0) : Get-NcVol -Query @{VolumeStateAttributes=@{IsNodeRoot=$false}}
Get all encrypted CIFS shares: Get-NcCifsShare -Query @{ShareProperties="encrypt_data"}
Get all volumes that have "root" in the name: Get-NcVol -Query @{Name="*root*"}
Get all volumes that do NOT have "root" in the name: Get-NcVol -Query @{Name="!*root"}
Get all volumes that are not vol0 or root: Get-NcVol -Query @{VolumeStateAttributes=@{IsNodeRoot=$false};Name="!*root*"}
Get all non-root volumes that are between 2GB and 1TB in size: Get-NcVol -Query @{VolumeStateAttributes=@{IsNodeRoot=$false};TotalSize="$(2GB)..$(1TB)";}
Get all volumes that are greater than 1Gb in size: Get-NcVol -Query @{TotalSize=">1GB"}
Hopefully some of those examples will help you.