โ04-18-2022 01:59 PM
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.
โ04-20-2022 03:43 PM
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
โ04-20-2022 04:18 PM
@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.
New to the site? Take a look at these additional resources:
Ready to join us? You can register here.