Software Development Kit (SDK) and API Discussions

Trying to figure out how to get properties of properties

Tas
3,666 Views

When I look at get-ncvol | gm, I see the primary properties, then  I see what I presume are object-properties.

i.e. get-ncvol | gm I see a few Property's, but then I see Property's flagged as (DataONTAP.C.Type.Volume...)

I'd like to get the information on these, for example the volumeSisAttributes;  if I run (get-ncvol).volumeSisAttributes | gm I see the list of additional SIS data I'd like to pull.  But I am unsure how to do that.  I don't really understand what kind of properties these sub-servient properties are, or how to get them via a PS get-ncvol structure.

 

Can anyone help?

 

TasP

4 REPLIES 4

mbeattie
3,632 Views

Hi Tas,

 

Not sure i've understood what you are trying to achiving but i hope this helps and makes sense.

 

 

#'------------------------------------------------------------------------------
Import-Module DataONTAP
Connect-NcController -Name cluster1 -HTTPS -Credential $(Get-Credential)
$volume = Get-NcVol -Name volume1 -Vserver vserver1
#'------------------------------------------------------------------------------
<#
If you invoke "$volume | fl" and pipe it to format-list you will see the volumes properties and sub object types. 
EG: DataONTAP.C.Types.Volume.VolumeSisAttributes
If you invoke the sub object type and pipe it to format-list you can enumerate the property names of the sub object.
EG: "$volume.VolumeSisAttributes | fl"
You can then access the volumes sub object property values by name.
EG: "$volume.VolumeSisAttributes.IsSisVolume"
#>
#'------------------------------------------------------------------------------
$volume.VolumeSisAttributes.IsSisVolume
True
#'------------------------------------------------------------------------------

/Matt

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Tas
3,576 Views

Matt:

 

Thanks.  I was trying to figure out the 'sub-object' (sub-properties?).  I still don't understand what a sub-object is.  What I was trying to do, is to get a listing of a certain set of volumes with the percentagetotalspacesaved for each, in a one-liner.

I think I may have to assign the volume properties to a variable and run via a foreach on each one to get the actual properties and sub-properties I need;  Oh and of course I need to pass them through the 'convertto-formattednumber' scriplet.

 

Tas

Semicolon
3,545 Views

 


@Tas wrote:

if I run (get-ncvol).volumeSisAttributes | gm I see the list of additional SIS data I'd like to pull.  But I am unsure how to do that.


You're looking to select custom properties.  This should get you in the right direction...

Get-NcVol -Name vol1 | Select-Object -Property Name,State,TotalSize,used,Available,Dedupe,@{n="PercentSpaceSaved";e={$_.VolumeSisAttributes.PercentageTotalSpaceSaved}}

To include the ConvertTo-FormattedNumber scriplet you referenced and a pretty percent sign...

Get-NcVol -Name vol1 | Select-Object -Property Name,State,@{n="TotalSize";e={try { ConvertTo-FormattedNumber $_.TotalSize DataSize "0.0" } catch [Exception] { $null }}},@{n="Used";e={try { ConvertTo-FormattedNumber $_.Used Percent } catch [Exception] { $null }}},@{n="Available";e={try { ConvertTo-FormattedNumber $_.Available DataSize "0.0" } catch [Exception] { $null }}},@{n="PercentSpaceSaved";e={ConvertTo-FormattedNumber $_.VolumeSisAttributes.PercentageTotalSpaceSaved Percent}}

Here is a primer on using Select-Object to view custom properties

Tas
3,516 Views

Thanks @Semicolon;  I will try out your suggestions.  I've been deperately looking for something like this.

Tas

Public