You know that VMware product that really lacked on the PowerCLI front called Horizon View? Well from PowerCLI 6.5 R1 it finally (try to imagine saying this like The Rock : Finally Powercli has come to Horizon View!) has its own module that you can use to talk to Horizon View and the View API’s.
Offcourse i am not the first to write about it and lots can already be found at the above link to the VMware blog by Graeme Gordon but I did want to share a couple of easy commands with you. I will not bore you with how to set it up because that’s already perfectly explained in Graeme’s post.
First we need to connect, looks like the connect-viserver right?:
connect-hvserver SERVERNAME
you will get a popup box for credentials, I haven’t found an option yet to do something like new-vicredentialstoreitem yet but you can use a hashed password in a text file.
Now for example to retrieve all disconnected desktops
Get-HVMachineSummary -State DISCONNECTED
This can be changed to whatever states are available for desktops.
One of the things Horizon View always lacked was proper reporting for desktop counts i.e. how many desktops are in what state. Lots of people had to use things like scripts that counted them from the adam database (sloooooow) or used tools like the VMware Horizon toolbox 2. To get a count is now really easy with powercli, just repeat the above command and do a count on it.
(Get-HVMachineSummary -State DISCONNECTED).count
For me this was a matter of a second with over 900 desktops available.
Want some information about a single desktop?
get-hvmachinesummary -machinename "machinename" | fl
In short you can find anything you want with the command or by using the View API’s. Since I am not an APi expert myself I would recommend heading over to the API browser and see what you want to use. In my next post I will dig into the command a bit more by grabbing the script from the VMware blog post and editing it more to my taste.