Access the diagnostic "data" in own code?

Hey all,
I really want to make calls to the sessions in the dashboard, anyknow know how to access this?

Hi @McAndersDK

If you do
$dash = get-uddashboard
I believe all the session stuff should be under there somewhere.
Care to elaborate the case? I’m a curious man :open_mouth:


1 Like

This dont seems to work.
the dashboard are running under IIS, and I want to access it from a scheduled endpoint.

(I use it for online counter :slight_smile: )

I use this atm:

New-UDEndpoint -Schedule (New-UDEndpointSchedule -Every 1 -Minute -consecutive) -id ‘OnlineUsers’ -Endpoint {

$StartTime = get-date

$ip = (Resolve-DnsName "$" -Type a -DnsOnly).ipaddress

function Get-NetStat {



This function will get the output of netstat -n and parse the output


This function will get the output of netstat -n and parse the output



Francois-Xavier Cat




        # Get the output of netstat

        $data = netstat -ano

        # Keep only the line with the data (we remove the first lines)

        $data = $data[4..$data.count]

        # Each line need to be splitted and get rid of unnecessary spaces

        foreach ($line in $data) {

            # Get rid of the first whitespaces, at the beginning of the line

            $line = $line -replace '^\s+', ''

            # Split each property on whitespaces block

            $line = $line -split '\s+'

            # Define the properties

            $properties = @{

                Protocole          = $line[0]

                LocalAddressIP     = ($line[1] -split ":")[0]

                LocalAddressPort   = ($line[1] -split ":")[1]

                ForeignAddressIP   = ($line[2] -split ":")[0]

                ForeignAddressPort = ($line[2] -split ":")[1]

                State              = $line[3]

                PID                = $line[4]


            # Output the current line

            New-Object -TypeName PSObject -Property $properties




$time = get-date

$newconnections = get-netstat | Where-Object { $_.LocalAddressPort -eq 443 -and $_.LocalAddressIP -eq $ip } | Select-Object foreignaddressip -Unique | Select-Object foreignaddressip, @{n = 'Timestamp'; e = { $time } }

$mergeConnections = $cache:OnlineUsers | Where-Object foreignaddressip -NotIn $newconnections.foreignaddressip | Where-Object Time -gt $time.AddMinutes(-5)

$mergeConnections += $newconnections

$cache:OnlineUsers = $mergeConnections

invoke-EndpointLogging -EndpointName 'onlineUsers' -StartTime $StartTime


as you can see it’s not pretty :stuck_out_tongue:
this would be much prettyer

New-UDEndpoint -Schedule (New-UDEndpointSchedule -Every 1 -Minute -consecutive) -id ‘OnlineUsers’ -Endpoint {
$dash = get-uddashboard
$cache:OnlineUsers = $Dash.DashboardService.EndpointService.SessionManager

Do this to get the list of sessions.

New-UDEndpoint -Schedule (New-UDEndpointSchedule -Every 1 -Minute -consecutive) -id ‘OnlineUsers’ -Endpoint {
$dash = get-uddashboard
$cache:OnlineUsers = $Dash.DashboardService.EndpointService.SessionManager.Sessions

Here’s the SessionManager class for reference.

1 Like

nope nothing is returned at all for any “path” of that variable.
get-uddashboard return nothing.

Oh. That’s weird. Let’s try this. This is just the internal class that Get-UDDashboard cmdlet is accessing.


Nope, dont return anything.

Here’s a full example that’s working for me.

$Dashboard = New-UDDashboard -Title 'hey' -Content {

   $Cache:SessionCount = 0

   New-UDCounter -Title Sessions -Endpoint {

$Schedule = New-UDEndpointSchedule -Consecutive -Every 5 -Second

$Endpoint = New-UDEndpoint -Endpoint {
   $Cache:SessionCount = ([UniversalDashboard.Server]::Servers.DashboardService.EndpointService.SessionManager.Sessions | Measure-Object).Count
} -Schedule $Schedule

Start-UDDashboard -Dashboard $Dashboard -Port 10000 -Endpoint $Endpoint -FOrce


yeah it seems to works standalone, but it dont work under IIS.

not sure why

I’m also interested in accessing the same info but can confirm, having the same issue under IIS, nothing is returned. It seems that the class / get-uddashboard itself doesnt return anything, let alone it’s sub properties. I can access the $session variable but obviously this is only for the current users session, not all.

I’m running UD 2.8.0, not had chance to test on 2.8.1 but I’ve not seen anything related under the open/closed issues within git. Adam, should I log a new issue for this?

I just realized the issue here. In IIS, using the -Wait parameter on Start-UDDashboard happens before the UD server object is added to that collection of servers so it never gets added to that list. I’ve put in a PR to fix this. 2.8.2 is going out the door today and this fix will be included.


Legend. As always, quick to the mark and super helpful. Thank You!

Related GitHub PR

This is now working (in version 2.8.2) BUT we need to use it like this:

else it just count 1. (And fixed for only returning Active sessions :))
Thanks for the fix @adam

1 Like