cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to: Report on system last contact within X days

BScott
Community Manager Community Manager
Community Manager

Our team got a question recently about seeing devices with uptime greater than a certain number of days beyond the notifications for devices inactive greater than 7 days. Here's how you can run that report using PowerShell Module. You can find these instructions & more on the support wiki on github.

Reporting on systems lastContact within X days

Get-JCSystem -filterDateProperty lastContact -dateFilter after -date (Get-Date).AddDays(-90) -returnProperties hostname, lastContact, created

This example will return a list of all systems that have not checked into the JumpCloud console in the last 90 days. Update the parameter .AddDays(-90) to modify the date range.

Get-JCSystem -filterDateProperty lastContact -dateFilter after -date (Get-Date).AddDays(-90) -returnProperties hostname, lastContact, created | Export-Csv JCSystemslastContact.csv

This example will output a csv of all systems that have not checked into the JumpCloud console in the last 90 days named JCSystemslastContact.csv. Update the parameter .AddDays(-90) to modify the date range.

Like someone's post? Give them a kudo!
Did someone's answer help you? Please mark it as a solution.

2 REPLIES 2

RyanBailey
Novitiate III

I took a stab at including system uptime since I think the original command would only include system last checkin. Note this requires System Insights to be enabled on your fleet. Great for shaming!

You could do this shorter but thought readability is a little more important. Think this method is the least amount of API calls and smallest bundle sizes, but curious if anyone else would approach differently!

$allSystems = Get-JCSystem -returnProperties os, version, hostname, active, serialNumber, lastContact, created
$uptimeTable = Get-JCSystemInsights -Table:('uptime') -SystemId:($($allSystems._id))

$allSystems | Select-Object -Property hostname, active, created, lastContact, os, version, serialNumber, @{
    Name       = "uptimeDays";
    Expression = {
        $currentId = $_._id
        $uptimeSeconds = $uptimeTable | 
            Where-Object { $_.systemId -eq $currentId } | 
            Select-Object -ExpandProperty TotalSeconds
        
        [Math]::Round([timeSpan]::fromseconds($uptimeSeconds).TotalDays, 2)
        }
    } | Export-Csv -Path "$env:USERPROFILE\Desktop\JCSystemUptime.csv" -NoTypeInformation

 

BScott
Community Manager Community Manager
Community Manager

@RyanBailey adding system uptime is an excellent idea. I think that's a perfect addition and probably more along the lines of what someone would be looking for anyway. Better hope that our Ryan Bacon doesn't run that on my machine. NOT tagging him so he doesn't. lol

Like someone's post? Give them a kudo!
Did someone's answer help you? Please mark it as a solution.