I was recent watching a PowerShell presentation where they mentioned a cool module called PowerShellCookbook and in particular discussed a cmdlet in it called Show-Object by Lee Homes. I instantly knew how perfect and powerful it would be with VMware’s PowerCLI Get-View.
Bare with me for a minute while I lay the ground work with Get-View. If you’ve ever used Get-View in PowerCLI you’ll know that it brings back a ridiculous wealth of information. When you run a cmdlet like Get-VMHost it’s really only bringing back a small subset of information back on that object. Sometimes this is fine but sometimes we need that little bit extra to reach our objective.
For example you can run Get-VMHost esxi01.ukoticland.local
What you get is a default formatted table view displaying only a few key values. A trick some of us do is then pipe this out to a list. Get-VMHost esxi01.ukoticland.local | Format-List
Heaps more information right, but it’s still not the full picture. There’s still a lot of information on this object that we’re missing. Take the original cmdlet we ran above and this time let’s pipe it to Get-View. Let’s also store it in a variable called $myHost, just so we can work with it.
$myHost = Get-VMHost esxi01.ukoticland.local | Get-View
Okay, on first glance it doesn’t look like much. But all those values that start with VMware.Vim are properties that can be drill down into. For example $myHost.Config and $myHost.Config.Capabilities
So it’s pretty cool right. We can now start retrieving a huge amount of new information that wasn’t available to use before. But this is like finding a needle in a haystack. I know I’ve wasted so much time typing $something dot something dot something in the hopes of finding a value I can work with.
Well finally this brings us to Show-Object. This is an awesome cmdlet that will let you display the object retrieved with Get-View in a grid view window that you can navigate through similar to a directory in File Explorer. Using it is as simply as piping our variable to Show-Object.
$myHost | Show-Object
Now we can explore and click around at everything available to us. As you navigate the object in the top pane for results you’ll get member data in the bottom pane. I see this becoming a great reference tool to help find what you’re looking for. Not only that but it will give you the syntax to retrieve the information selected in the view pane.
So how do you get Show-Object? Well, it’s not in PowerShell by default but can easily be obtained from the PowerShell Gallery, which, if new to you, is basically a public repository for PowerShell content. If you’re using Windows 10 you’re half way there. If not go get yourself the Windows Management Framework (WMF) 5. This will give you the latest version of the PowerShellGet module. Then it’s just a matter of typing Install-Module -Name PowerShellCookbook.
Once the module is installed from the PowerShell Gallery, Show-Object is now available to use. It’s worth noting that PowerShellCookbook comes with a huge array of extra cmdlets also worth exploring.
Finally if you do try out Show-Object and like it, there’s a “jacked up” version of it over at PoshCode by Justin Rich