The VI Toolkit (for Windows) focuses on making VMware management easy and automatable. One thing you’ll notice if you use the toolkit for a while is that the objects you get from cmdlets like Get-VMhost, Get-VM, etc. don’t have all the properties that are available through the VI Client. This is because in the Toolkit, we use what we call "Automation Objects", which are simplified representations of the full object model. For various reasons, the automation objects may not have the data you need. In this case, using the Get-View cmdlet, you can load the full representation (or "View") that has all of the objects data in it.
As Eric Sloof blogged a while back, there are a lot of interesting properties hiding behind the automation objects, and shows how to get at them. If you’re interested in learning more about what’s behind your objects, I’ve got a script, Get-ViewProperties.ps1 that can help. When you start the VI Toolkit (for Windows) you can either "dot source" this function in, or just copy and paste it into your window. Then, when you pass a view to Get-ViewProperties, all of its properties are printed to the console. This is a great way of exploring your objects and can help you create some really powerful reports.
Here are some screenshots of the script in action. As always, first we log in and this time I’ll load a host object for us to examine (click on the image for a better look):
Let’s pass this variable to the script:
That’s over 150 properties, quite a lot of stuff hiding in there!
Let’s try the same with a VM:
Again, that’s quite a lot of properties.
In case you’ve never seen it, you can get a hold of the same data using something called the managed object browser (or MOB), by navigating to https://<yourserver>/mob. The MOB can be a bit of a challenge to navigate at times, and the nice thing about this approach is that all nested data is presented at once. The advantage of using the MOB, however is that you can transition from one managed object to the other (say, from VM Host to VM), which this script doesn’t do.
Again, there’s a lot of good stuff in here that can serve as a great foundation for reporting. If you find anything really good, let us know about it, on the blog or on the forum.