VMware Cloud Community
MattG
Expert
Expert

Easy way to search for and browse Managed-Object properties?

I am currently using the SDK's online reference:

https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/index-mo_types.html

To search for the various ESX properties to pull with the get-view Powershell command. However, this is tedious as you can't search the SDK web pages (is their a .chm equivalent?).

Is there an easier way to locate this info or is this it?

I am at the point that I started entering the items that I am using into an Outliner program like this:

-Config

-Network

-Vswitch

-Name

-Key

This way I can see that my command would be Config.Network.Vswitch.Name to pull up all vSwitch names on the host. I can also put notes beside each object/property so that I can easily search for text.

When you type the Object in the VI PS cli it gives you the sub object/properties and their values. For example:

config.network.vswitch will produce:

Name: vswitch0

Key: blah-blah

Is there a way to get a list of the sub object/properties without the values? This would make it easier for me to import these values into the Outliner software if that is direction I need to go in. Doing it the current VI-SDK html lookup way is confusing once you start drilling down because you forget with the parent object was.

Any assistance would be appreciated.

Thanks,

-MattG

-MattG If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
6 Replies
MattG
Expert
Expert

Would be cool if a script could be created to dump all subproperties (and nested subprops of the subprops) of the config. object to a text file.

I would think this is doable?

-MattG

-MattG If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
halr9000
Commander
Commander

Yes, it is. I've been thinking about this a little bit today but haven't gotten around to it. Basically you would pipe a view to get-member, then iterate through that collection.

get-vmhost | get-view | get-member -memembertype property | foreach-object {
    $_ | format-table Name, Definition -auto
    if ( $_.definition -like "VMware*" ) { go deeper here } 
}


[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
hugopeeters
Hot Shot
Hot Shot

I recently did a recursive query of groups ánd a show-tree command on my website which are similar scripts. I'll give this a go later today.

Hugo

www.peetersonline.nl

Reply
0 Kudos
hugopeeters
Hot Shot
Hot Shot

WOW! That was actually pretty hard... But I did it!

Here's my results:

http://www.peetersonline.nl/index.php/vmware/list-all-available-properties-in-the-vi-toolkit/

Regards,

Hugo

MattG
Expert
Expert

Hugo,

Awesome! That was exactly what I was looking for. Outputting the first command to a txt file allows me to quickly search

for properties and their values.

Question: Is it possible to have the script dig down further?

For example:

$VMView = get-vmhost esx01.abc.com|get-view

$VMView.Config.Network.Pnic

Returns the following info for all of the physical nics on the box:

  • Key : key-vim.host.PhysicalNic-vmnic2

  • Device : vmnic2

  • Pci : 15:00.0

  • Driver : e1000

  • LinkSpeed :

  • ValidLinkSpecification : {VMware.Vim.PhysicalNicLinkInfo, VMware.Vim.PhysicalNicLinkInfo}

  • Spec : VMware.Vim.PhysicalNicSpec

  • WakeOnLanSupported : True

  • Mac : 00:1f:24:53:00:e1

  • DynamicType :

  • DynamicProperty :

From here I could do:

$VMView.Config.Network.Pnic[0].spec.ip

And get:

  • Dhcp : False

  • IpAddress :

  • SubnetMask :

  • DynamicType :

  • DynamicProperty:

I know this will create alot of data as it iterates through the array of objects, but the data that it produces will be the definitive document on my host's settings.

Again thanks for the effort as this is a big help.

-MattG

-MattG If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
hugopeeters
Hot Shot
Hot Shot

Hi Matt,

I've updated my post here http://www.peetersonline.nl/index.php/vmware/list-all-available-properties-in-the-vi-toolkit/

I've dropped the tree view, because it is too dificult to track back all the parent property names. The collection view now recurses into array's as well. I first made it list ALL members of each array. But that was a bad move. It returns a near infinite amount of properties for each attached LUN. So it now lists only the properties for the first element in each array.

Have fun!

Hugo

Reply
0 Kudos