Andrew Morgan - from the trenches

Subscribe to Andrew Morgan - from the trenches feed
Grumpy ramblings
Updated: 1 hour 56 min ago

Using the VMware Horizon API from c#

Tue, 03/13/2018 - 12:43

So here’s an ask I’ve had for well over a year, which i duly neglected until the mind of the brilliant Sean Massey decided to send me a PM on the vExpert EUC slack channel.

VMware Horizon’s API has been published for well over a year at this point over on code.vmware.com but there’s two challenges with this API in my humble opinion:

A: it’s WAAAAY too developer orientated for a regular PowerShell consumer*

B: while it’s a fully fledged API it seems a bit shortsighted to only document how to use it from Powershell given that the full API is documented.

* oh don’t have such a high opinion of yourself, everyone complained, i have the emails to prove it!

I had attempted this a few times before, but my usual source of help, Remko was too busy to help me or I duly hit a problem and inevitably toddled off to do something else. Not this time! and with no Remko help! *pats self on the back*

Any-who, here’s the deal. Up to now, despite writing community tools for years, i had never actually figured out Github, so i decided now was the time.

Over on my new and shiny GitHub repo, you’ll find a sample project on how to utilize the Powercli libraries directly in c# for access to Horizon.

If you’re old-school and find this whole GitHub thing a bit much, I’ve included the source c# project here for download too!

Here’s a screenshot of the actual example utility for, y’know, pictures!

 

Categories: Community, Virtualisation

Viewing VMware Unified Access Gateway statistics with REST

Fri, 03/09/2018 - 12:38

<Tap Tap> Is this thing still on? Good!

The VMware Unified Access Gateway really is a wonderful device. With a quick deployment of an OVF you’re up and running with free remote access to your VMware Horizon environment. The device is so simple in fact, that it’s often a case of set and forget, it does the hard work freeing you up to do more important things.

A request came in from a customer last year to be able to view more about what this little magic appliance is doing, how healthy it is and how many  users it is currently servicing.

For VMware vRealize Operations for Horizon customers, this data is all available directly in the VROPS portal, but what if you don’t have VMware vRealize Operations for Horizon? or want to query this in an automated fashion?

Well the good news is, the clever engineers behind this project not only allowed RESTful configuration of the product, they also allowed restful retrieval of the information too!

if  you browse to https://<your device IP or name>:9443/rest/v1/monitor/stats you’ll get all the info you could want as below: (after you authenticate, of course).

In the XML REST response you get above, you’ll get the information about the device health and also the services (horizon, authentication, etc.).

So that’s great, but wouldn’t it be nice if we could get that information from PowerShell too?

I’ve thrown together a Powershell module here you can use or hack apart for your own purposes to allow you to query your own Unified Access Gateway appliances.

Simply import the module:

from here you can see the exported cmdlets:

and here are the two exports below:

Get-VMwareUAGHorizonStats:

Get-VMwareUAGHealth:

 

So that’s it! A big thank you to my colleague Mark Benson for the endless, cheerful help. Despite how much of a pest i can be!

Categories: Community, Virtualisation