Whilst working on my Horizon View API page, trying to figure out which API calls return the data that you can see in the Horizon Administrator Console, it soon became clear that the API Query Service is used to collect a lot of the data seen within the UI. The way I managed to figure this was by analyzing a Horizon View Example Desktop Script created by Alan Renouf. So I’m going to try and document how to use the Query Service here so that other can use begin to use this really powerful tool.
Hopefully, this will be useful to you. If you have any questions, please either comment below or contact me directly. I will update this page as I learn more.
C:\> $ViewAPI = $global:DefaultHVServers[0].ExtensionData C:\> $query_service = New-Object "Vmware.Hv.QueryServiceService" C:\> $query = New-Object "Vmware.Hv.QueryDefinition"
C:\> $query.queryEntityType = 'DesktopSummaryView'
C:\> $Pools = $query_service.QueryService_Query($ViewAPI,$query)
C:\> $Pools.Results.DesktopSummaryData Name : CorpIT-Image-IC DisplayName : CorpIT Image v1 Enabled : True Deleting : False Type : AUTOMATED Source : INSTANT_CLONE_ENGINE UserAssignment : FLOATING AccessGroup : VMware.Hv.AccessGroupId GlobalEntitlement : VirtualCenter : VMware.Hv.VirtualCenterId ProvisioningEnabled : True NumMachines : 2 NumSessions : 0 Farm : Name : CorpIT-Image-v2 DisplayName : CorpIT Image v2 Enabled : True Deleting : False Type : AUTOMATED Source : INSTANT_CLONE_ENGINE UserAssignment : FLOATING AccessGroup : VMware.Hv.AccessGroupId GlobalEntitlement : VirtualCenter : VMware.Hv.VirtualCenterId ProvisioningEnabled : True NumMachines : 2 NumSessions : 0 Farm : Name : UEM-Pool DisplayName : UEM-Pool Enabled : True Deleting : False Type : AUTOMATED Source : VIEW_COMPOSER UserAssignment : FLOATING AccessGroup : VMware.Hv.AccessGroupId GlobalEntitlement : VirtualCenter : VMware.Hv.VirtualCenterId ProvisioningEnabled : True NumMachines : 5 NumSessions : 1 Farm : Name : WIN10-IC DisplayName : Win10 Instant Clones Enabled : True Deleting : False Type : AUTOMATED Source : INSTANT_CLONE_ENGINE UserAssignment : FLOATING AccessGroup : VMware.Hv.AccessGroupId GlobalEntitlement : VirtualCenter : VMware.Hv.VirtualCenterId ProvisioningEnabled : True NumMachines : 3 NumSessions : 1 Farm : Name : WIN10-LC DisplayName : Win10 Linked Clones Enabled : True Deleting : False Type : AUTOMATED Source : VIEW_COMPOSER UserAssignment : FLOATING AccessGroup : VMware.Hv.AccessGroupId GlobalEntitlement : VirtualCenter : VMware.Hv.VirtualCenterId ProvisioningEnabled : True NumMachines : 3 NumSessions : 0 Farm :
C:\> $query.queryEntityType = 'MachineSummaryView' C:\> $Desktops = $query_service.QueryService_Query($ViewAPI,$query) C:\> $Desktops.Results.Base Name : UEM-002 DnsName : uem-002.lab.local User : AccessGroup : VMware.Hv.AccessGroupId Desktop : VMware.Hv.DesktopId Session : BasicState : AVAILABLE Type : MANAGED_VIRTUAL_MACHINE OperatingSystem : Windows 7 AgentVersion : 7.0.1 AgentBuildNumber : 3989057 RemoteExperienceAgentVersion : RemoteExperienceAgentBuildNumber : 24222 Name : UEM-005 DnsName : uem-005.lab.local User : AccessGroup : VMware.Hv.AccessGroupId Desktop : VMware.Hv.DesktopId Session : BasicState : AVAILABLE Type : MANAGED_VIRTUAL_MACHINE OperatingSystem : Windows 7 AgentVersion : 7.0.1 AgentBuildNumber : 3989057 RemoteExperienceAgentVersion : RemoteExperienceAgentBuildNumber : 24222 Name : UEM-004 DnsName : uem-004.lab.local User : AccessGroup : VMware.Hv.AccessGroupId Desktop : VMware.Hv.DesktopId Session : VMware.Hv.SessionId BasicState : DISCONNECTED Type : MANAGED_VIRTUAL_MACHINE OperatingSystem : Windows 7 AgentVersion : 7.0.1 AgentBuildNumber : 3989057 RemoteExperienceAgentVersion : RemoteExperienceAgentBuildNumber : 24222
Another VMworld is upon us!!! Sadly, it's only virtual again this year. However, that does…
As part of my recent move to Google, I'm working on quickly getting up to…
I am delighted to announce the next chapter in my career. Today is my first…
In episode thirteen of The VCDX Podcast, I am joined by two special guests who…
In my recent ‘Getting started with Oracle Cloud VMware Solution (OVCS)’ post; Getting Started With…
In my recent ‘Getting started with Oracle Cloud VMware Solution (OVCS)’ post; Getting Started With…
View Comments
Have you found a way to query the health status of vCenter as displayed in View Admin? i.e. Green or Red in View Admin = something/somewhere in the API? I spent a while poking and found the VMware.HV.VirtualCenterHealth stuff in the API but none of its methods or properties seemed to contain the current status, same for the security and connection server objects.
Since there is no log for the services changing status and Horizon Events doesn't track them either, I was hoping i could pull the status through the API and maybe from there figure out how to generate an alert when my services changed to Red.
Good question. This would be really handy. Let me see what I can find.
I can't see anything either. I'll see if I can ask internally.
Let me know if you find any answers. I've got this tagged to work on if i can ever find the values in the API.
I've head back from the Dev team:
They can use these health VIEW APIs (ADDomainHealth, CertificateSSOConnectorHealth, ConnectionServerHealth, EventDataBaseHealth, FarmHealth, PodHealth, SamlAuthenticatorHealth, SecurityServerHealth, ViewComposerHealth, VirtualCenterHealth ) and able to generate alerts via powerCLI.
I've not had any spare time to test it yet though.
$global.DefaultHVServers.extensiondata.VirtualCenterHealth.VirtualCenterHealth_LIST().connectionserverdata has some Status values that look promising. Interestingly enough 3 of my ConnServers are showing STATUS_UP while one is STATUS_DOWN. But at least i think i'm on the right track now.
https://vdc-repo.vmware.com/vmwb-repository/dcr-public/f004a27f-6843-4efb-9177-fa2e04fda984/5db23088-04c6-41be-9f6d-c293201ceaa9/doc/vdi.health.VirtualCenterHealth.ConnectionServerConnectionData.html
Thanks for this information, I am able to connect and use the examples! How would I be able to use this now to be able to reset or remove a virtual desktop using the API, for example a floating pool machine is in error and I want to automate the removal of it? I found the commands in the API, but I am confused on how to do this - any ideas?..Thanks!
Excellent! Thank you for this information.