Session Count Per Pool Report

This post was originally published on this site

Hi Guys,

 

I am trying to make a script which gives count of available, connected and disconnected sessions of all the desktop pool as a csv report.

 

Below is the script which gives count of available, connected and disconnected sessions of a single desktop pool.

 

$pool = Read-host “Enter the pool name”

$tmp = Get-HVPool -PoolName $pool | Select -ExpandProperty base | Select -expandproperty name | % {Get-HVMachineSummary -PoolName $_| Select -ExpandProperty base | Select name,basicstate}

$Dname = (Get-HVPool -PoolName $pool).base.name

$Results = New-Object PSObject -Property @{

 

        “Available” = ($tmp | where {$_.basicstate -eq “AVAILABLE”});

 

        “Connected” = ($tmp | where {$_.basicstate -eq “CONNECTED”});

 

        “Disconnected” = ($tmp | where {$_.basicstate -eq “DISCONNECTED”});}

$Available = ($Results.Available).Count

$Connected = ($Results.Connected).Count

$Disconnected = ($Results.Disconnected).Count

$Total = $tmp.Count

write-host “Desktoppool name:” $Dname

write-host “Total Systems in the pool are:” $Total

write-host “Available Systems in the pool are:” $Available

write-host “Connected Systems in the pool are:” $Connected

write-host “Disconnected Systems in the pool are:” $Disconnected

#End

 

How to get these details for all the desktoppools?

 

Expected csv output:

 

    

Desktoppool Name Total Available Connected Disconnected
Desktop-01 10 5 3 2
Desktop-02

 

Any help?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.