I have been using Powershell/PowerCLi a bit more with VMware Horizon lately, so I wanted to take a couple of posts to share a few things.

The first is just how to use PowerCLI with Horizon.

If you haven’t install PowerCLI yet, let’s start there. You can do it with a simple

Install-Module VMware.PowerCLI

After PowerCLI is installed we can check and see which modules from VMware are available and look for Horizon

And we can import the Horizon Module

Now that all of the setup is done we can take a look at which cmdlets are available to us using the get-help or help cmdlet. Since all or most of the cmdlets have HV in the noun portion of the cmdlet, we can search for them using:

get-help get-hv*

Granted this will only show us the Get cmdlets, but we could also easily look up the Set cmdlets using the same method.

Now there are a couple of things to note about these functions/commands. All of the commands with “Summary” at the end will give you nicely formatted output with relevant information. The other commands will just return to you the object. Here is an output from a Summary command

As we can see, everything is in a table format, much as we would expect when doing a normal get command.

This however, is not as helpful. Instead of getting information a table with basic info about the Pools, we just get the pool objects.

On top of this, the Summary commands also don’t operate like we would normally expect. For instance, let’s say we just want to show the machine and desktop columns from the Get-HVMachineSummary command

Uhhmm, that doesn’t seem right. How about showing all the fields of the same command.

Again, that isn’t what we would expect. This is however the objects for the machine, just not the nicely tabled version we had earlier.

So basically the Summary commands present table as is, but if you want to change how they are formatted, you are kind of out of luck for a simple way to do that.

There is one kind of way around this though. Most of the relevant information we would want is under the Base properties of the objects. So if we run the same command but select and expand base.

From here we would be able to start selecting out specific information if there are specific tables or output we want to create.

I hope this helps. My next post will demonstrate how to create some of our own objects with the Horizon command, and how to dig in a little deeper to get at some information that isn’t available with the normal Get-HV* commands.


1 Comment

Creating custom powershell objects for Horizon desktop info – vNoob · September 1, 2020 at 3:06 pm

[…] my last post we talked about getting started with using powercli to get information from Horizon. We even talked […]

Leave a Reply to Creating custom powershell objects for Horizon desktop info – vNoob Cancel reply

%d bloggers like this: