VMware Cloud Community
Mecallie
Contributor
Contributor

Get available VDI's with PowerCLI.

Hi folks,

We are running a VMWare View 5.1 enviroment with about 320-340 users concurrent. Recently we had some issues with provisioning and we had to check the available/(dis)connected count by hand every evening after most users logged off. (We roll out a new machine immediatly after a user logs off, no refresh).

Is there a way to get the number of available VDI's in a pool and the number of (dis-)connected users in a pool via a PowerShell script? Ideally we would like an export for this so Nagios (our monitoring solution) can see if the number of available desktops minus the connected/disconnected desktops matches the max number of desktops we set in the View connection server. Right now we can only see if provisioning is disabled in Nagios, not the number of available VDI's.

I have found some scripts for the ADAM database and even one for the unofficial PowerCLI scripts, but none seem to work on 5.1 or 5.2 or they just don't provide the needed output...

TIA!

7 Replies
LucD
Leadership
Leadership

Try something like this

Get-Pool | %{
 
$remote = Get-RemoteSession -Pool_id $_.Pool_id
 
$_ | Select @{N="Name";E={$_.Pool_id}},
   
@{N="VM in pool";E={Get-DesktopVM -Pool_id $_.Pool_id | Measure-Object | Select -ExpandProperty Count}},
   
@{N="Connected";E={$remote | where {$_.State -eq "CONNECTED"} | Measure-Object | Select -ExpandProperty Count}},
   
@{N="Disconnected";E={$remote | where {$_.State -eq "DISCONNECTED"} | Measure-Object | Select -ExpandProperty Count}}
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Tmgenesys
Contributor
Contributor

In looking at Luc's reply, I'm not sure how this gets a count of VMs in an 'available' state in the pool.  I'd like to simply get the available count and notify (send email) if it drops below a certain threshold.  While we have a minimum number of VMs defined, it takes a while to automatically clone and spin up new machines in our environment so we're looking for a way to schedule a check every so often via Task Scheduler (say, 5 minutes) and check number of available servers.  I understand we can get count of remote-sessions and local-sessions, but that doesn't seem to account for machines that may be in agent unreachable, already used, or other states.  Basically, I'm just looking for the number of available servers that would match the count of available servers in the View GUI.

0 Kudos
LucD
Leadership
Leadership

Isn't "VM in pool" minus "Connected" and "Disconnected", giving you the Available number you see in the GUI ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Tmgenesys
Contributor
Contributor

In my current view pool, I have 20 VMs.  7 are in use/connected, 3 are in 'Error' state (network issue), 1 is in 'Maintenance Mode'.  This means that I really only have 20 - (7+3+1) = 9 machines available for users.  The script above outputs result that shows 20 total VMs, 7 'Connected', and 0 'Disconnected'.  The goal is to notify if there are fewer than X number of machines in an available state.

In other words, it doesn't account for other states that a VM may be in (like Error, Maintenance Mode, Agent Unreachable, Provisioning, Already Used, etc ...).

0 Kudos
LucD
Leadership
Leadership

Afaik these states are not available through the cmdlet, you probably have to go and query the ADAM DB


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Mecallie
Contributor
Contributor

Thank you for your replies LucD. Unfortunately the info is still not available through the cmdlets in Horizon VIEW 6 (or 7 as far as I know).

I do not understand why VMWare does not make these available. I would assume every sysadmin would want to know the number of machines in available, error, already used, provisioned, etc. etc. stats. Really bizare that they still have not implemented this in the api.

In the mean time: can you help us getting this information from the adam db itself? We really need to do monitoring on our VDI enviroment...

0 Kudos
Chaitanyakumar_
Enthusiast
Enthusiast

I know it is an year by now, but I wrote a small command to get the result. Hope this helps if anyone is looking for it.

This would list pool names with the available unassigned desktops in the pool.

Add-PsSnapin Vmware.View.Broker

Get-Pool | Select Pool_id, @{Name="Unassigned VMs";Expression={($_ | Get-DesktopVM | ? {$_.user_displayname -eq "$null"}).Count}}

Thanks,

Chaitanya.

0 Kudos