Export ViewBase object properties and child objects properties with PowerCLI.
The script below has been created initially to extract the list of all properties and child properties of any ViewBase object to ease the creation of another script in another project that will be released soon.
It also generate a XML file as a “kind” of UML diagram for this object and all child objects.
The data are extracted from “vmware.vim.dll”
Installed by default with PowerCLI
Auto-generated .Net binding to the vSphere API on which the vSphere PowerCLI is developed
Information in this “dll” are very close to the information available in the “VMware vSphere API Reference” however there are some differences.
The list below is non-exhaustive:
Properties added like “LinkedView”,”Client” etc
“synchronous” functions insted of just the “asynchronous” Example for ClusterComputeResource: “ReconfigureCluster” and “ReconfigureCluster_Task”
One script, two functions:
This script can be used in two way with two different functions, so you can select the one that is matching your needs.
The first one “Export-APIPropertiesRecursiveToXMLWithoutDuplicates” is the fastest.
If one object has already been analysed previously the script will not attempt to identify all properties associated to this object again.
The other “Export-APIPropertiesRecursiveToXMLWithDuplicates” will export all properties of every objects even if this object has already been analysed in another branch.
One exception however, to avoid infinite loop, if an object has already been analysed in its own “parent” branch, properties will not be exported again.
Example of files generated:
(Right click and select “save link as”)
$FullnameOfTheObjectToAnalyse = "VMware.Vim.ComputeResource" Export-APIPropertiesRecursiveToXMLWithoutDuplicates -ObjectToAnalyse $InitialObjectToAnalyse -IgnoreNestedObjectForInitialObject $True
$FullnameOfTheObjectToAnalyse = "VMware.Vim.VirtualEthernetCard" Export-APIPropertiesRecursiveToXMLWithDuplicates -ObjectToAnalyse $InitialObjectToAnalyse -IgnoreNestedObjectForInitialObject $False
Example of code generated in PowerCli prompt:
This code will be used in a another script.
For example for “VMware.Vim.VirtualEthernetCard” the first lines will be:
'AddressType',` 'AllowGuestControl',` 'Backing',` 'BackingObjectId',` 'ChangeId',` 'ChoiceInfo',` 'CompatibilityMode',` 'Connectable',`