Obtaining All Member Information from Get-NcXXXXX

I’ve got a mini-project to get all the configuration information from NetApp Clustered ONTAP Clusters, Nodes, SVMs ... with the aim of creating a config comparator program (i.e. compares configuration to check for mis-configurations against a given standard, and/or things missing from a DR SVM.) The first step is getting all the Get-NcXXXXX information.

The following functions (Display-AllMembers and MemberData) are quite nice in that you can just input into the function the output of a Get-NcXXXXXX and it gives out all the individual data elements. I’ve added three examples (which are the only 3 tested so far) in the main program section, to show how to use the function. They require the Data ONTAP PowerShell toolkit is installed, and there is an existing connection to a Cluster,

PS Next step is to go through all 267 Get-Nc’s (as given by: PS> (get-nchelp get-nc*).count) and decide what is needed.

###############
## Functions ##
###############

Function MemberData {

$memberType = $member.MemberType
If($memberType -eq "Method"){return}

$memberName = $member.Name
$data = $inputToFunction.$memberName
$definition = $member.Definition
"$memberName=$data"

# Return if no data
If ($data -eq $null){return}

# Return to the following common definitions/types where we're not interesting in the sub-members
If ($definition.Contains("bool")){return}
If ($definition.Contains("string[]")){return}
If ($definition.Contains("NcController")){return}
If ($definition.Contains("System.Object")){return}
If (($inputToFunction.$memberName).gettype().name -eq "String"){return}
If (($inputToFunction.$memberName).gettype().name -eq "Boolean"){return}
If (($inputToFunction.$memberName).gettype().name -eq "TimeSpan"){return}
If (($inputToFunction.$memberName).gettype().name -eq "DateTime"){return}

$checkIfSubMembers = $inputToFunction.$memberName | gm
$countOfSubMembers = $checkIfSubMembers.count
If ($countOfSubMembers -ne 0){"$countOfSubMembers SUB-MEMBERS DETECTED!!!"}
# If want to display the sub-members, display by un-hashing the next line:
# $inputToFunction.$memberName | gm
      
} # END Function MemberData

Function Display-AllMembers{
$inputToFunction = $args[0]
$getMembers = $inputToFunction | gm
foreach ($member in $getMembers){MemberData}}

Function CustomDisplayDateTime{
$dateAndTime = get-date
"################################"
"##### " + $dateAndTime + "  #####"
"################################"}
      
####################
### MAIN PROGRAM ###
####################

CustomDisplayDateTime

$vserverInfo = get-ncvserver PRICLU1V1
Display-AllMembers $vserverInfo

CustomDisplayDateTime

$nodeInfo = get-ncnode NACLU1N1
Display-AllMembers $nodeInfo

CustomDisplayDateTime

$asupInfo = get-ncautosupportconfig NACLU1N1
Display-AllMembers $asupInfo

Comments