I’ve started rewriting my VMware daily report to use Get-View, rather than the related PowerCLI commands wherever possible, for performance reasons. One minor inconvenience with this is that the view objects returned often have many properties, many of which are objects themselves. Some properties are nested four or more levels deep.
So I’m trying to create a function which will output all properties of an object, along with the full path to that property. This could then be piped to Where-Object, to make finding specific properties easier. So to find a property relating to Host on a VMware.Vim.VirtualMachine object stored in $v, I would type something like:
Get-Properties -Object $v | ? {$_ -match "Host"}
And ideally, this would return a list of all nested properties of $v which contain the word “Host”.
How can I do this?
Perhaps there is an easier way to do this, but here’s what I came up with:
When running it using the command
it returns
Considering that the VMware.Vim.VirtualMachine object has 5087 nested properties, this is a much easier way to find what you’re looking for. Hopefully this can help someone else.