Skip to content

Instantly share code, notes, and snippets.

@scottd3v
Last active July 15, 2022 16:18
Show Gist options
  • Select an option

  • Save scottd3v/c050f8f8426be2cc1894fb85fcd3bf41 to your computer and use it in GitHub Desktop.

Select an option

Save scottd3v/c050f8f8426be2cc1894fb85fcd3bf41 to your computer and use it in GitHub Desktop.
<#
Example script using the JumpCloud PowerShell module to search for macOS devices that do not have the JumpCloud service account that have been active in the last X days.
The variable $ActiveInLast_X_Days is by default set to 30. This value can be modified
#>
#---Editable Variables-----
[Int]$ActiveInLast_X_Days = '30'
#------DO NOT MODIFY BELOW------
$SearchParams_InactiveSystems = @{
OS = 'Mac OS X'
filterDateProperty = 'lastContact'
dateFilter = 'after'
date = "$($(Get-Date).AddDays(-($ActiveInLast_X_Days)))"
}
#Search for inactive systems with contact in last X days
$SearchResults = Get-JCSystem @SearchParams_InactiveSystems
$SearchParams_ActiveSystems = @{
OS = 'Mac OS X'
active = $true
}
#Search for active systems and add results to search results
$SearchResults += Get-JCSystem @SearchParams_ActiveSystems
#Search for device without the service Account
$SearchResults | Where-Object hasServiceAccount -EQ $false | Select-Object hostname, _id, hasServiceAccount, lastContact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment