Powershell script to identify active users who have enrolled their device in JAMF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
08-30-2019
02:16 PM
- last edited on
03-04-2025
02:57 AM
by
kh-richa_mig
Hi everyone,
I am trying to figure if we can write something in powershell to query all the active users associated to a device enrolled in JAMF. Trying to setup some automation on a Windows box. Any helpinsight will be highly appreciated.
- Labels:
-
Jamf Pro

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-30-2019 02:46 PM
I’d think MySQL queries would be the more logical route. Jamf doesn’t utilize anything close to power shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-30-2019 04:10 PM
I'm pretty sure it can be done. You'll need to get familiar with the API.
Look into using PowerShell's Invoke-RestMethod for the PowerShell piece.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-30-2019 08:14 PM
yeah you will have to look at the API and look at PS cmdlets for interacting with APIs. PowerShell is a complete language and it has HTTP libs in it. There are multiple ways to interact with a REST API though in PS. There is Invoke-RestMethod
and there is also Invoke-WebRequest
. Both have slightly different use cases. PowerShell, in my limited experience with the language thus far, seems to always give you several options, each with different uses or edge cases they are not good for, or are perfect for. So, you'll have to do some testing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-30-2019 08:40 PM
I did a very quick and dirty test based off the MSFT docs
$uri = 'https://yourjamfserver.com/JSSResource/categories'
$creds = "user:password"
$encodedcreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($creds))
$headers = @{ Authorization = "Basic $encodedcreds" }
$data = Invoke-RestMethod -Uri $uri -Method Get -Headers $headers -UseBasicParsing
$data
xml categories
--- ----------
version="1.0" encoding="UTF-8" categories
$data.InnerXML
When I ran $data.InnerXML
it printed the output in the PS terminal
