How Can We Help?
< Back
You are here:
Print

The case of the missing property

With the Get-Inventory cmdlet you can retrieve the available items in your vSphere environment.

This should allow us to extract all objects of Type VMHost.
Right?
No, it doesn’t.
The following code returns no object(s).

The explanation are the Extended Data Types that PowerCLI uses. The Extended Data Types are defined in .ps1xml files, and can be located in the PowerCLI module folders.

In this case we are looking at the .ps1xml files that come with the VMware.VimAutomation.Core module.

In there we find the Type field under the InventoryWrapper entry. And the Type field is a ScriptBlock, meaning there is some code executed to display this property.

Now that we know how the value of the Type property is obtainedm, we can adapt the Where-clause we used earlier.

And this allows us to extract the objects we were trying to get at the beginning.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Table of Contents