Posted on 08-30-2019 02:16 PM
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.
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.
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.
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