Smart Computer Group API

New Contributor

Hey JAMFs!
I try to automate the creation of Smart Computer Groups by API (within Powershell) based on the installed Apps criteria.

I'm a bit confused as I don't find anything in the API-documentation fpr smart-computer-group with method POST.

I already have a filtered list of all required groups with app name, path and name for the group.


Contributor II

The API reference has it under 'Computer Groups' and one of the tags is to define if its a smart group or not:

New Contributor

Thanks, I didn't find the reference at first, only had the short documentation.
I managed to create the "sync".
My next goal would be a match against the Labels.txt of the installomator, what really isn't that simple as I hoped....

New Contributor III
New Contributor III

Depends how automated you're looking to go. Creating a script to create the smart computer groups off a list that you feed the script (whether a file or manually putting it in) wouldn't be too bad. If you want to pull that information from somewhere that may be harder. 

You can't access the ... list of the installed apps criteria, you'd need to for example pick a computer and then use an API call to pull all the apps that it has (assuming it has the full list of apps you'd want)

New Contributor

It works so far:

$clientid = "<clientid>"
$clientsecret = "<cleintsecret>"
$baseURL = "https://<yourcompany>"

$body = @{  client_id = $clientid
            client_secret= $clientsecret

try {
    $token=Invoke-WebRequest -Uri $baseURL"/oauth/token" -ContentType "application/x-www-form-urlencoded" -Body $body -Method POST
Catch [System.Net.WebException] { $exception = $_.Exception
            $respstream = $exception.Response.GetResponseStream()
            $sr = new-object System.IO.StreamReader $respstream
            $ErrorResult = $sr.ReadToEnd()
            write-host $ErrorResult 
$token = $token.Content | ConvertFrom-Json
$token = $token.access_token

$auth = "Bearer $token"

$AllEntries = Invoke-WebRequest -Uri $baseurl"/api/v1/computers-inventory?section=APPLICATIONS&page=0&page-size=100&" -Headers @{Authorization=$auth} -ContentType "application/json" -Method GET -Verbose
$AllEntries = $AllEntries.Content
$AllEntries = $AllEntries | ConvertFrom-Json

foreach ($Computerentry in $AllEntries.results)
    foreach ($appentry in $Computerentry.applications)
        if ($appentry.path -notlike "/System/*")
            Write-Host $
            Write-Host $appentry.path
            $Groupname = "Software - "+$".app","")
            Write-Host $Groupname
<name>Application Title</name>

Invoke-WebRequest -uri $baseurl"/JSSResource/computergroups/id/0" -Headers @{Authorization=$auth} -ContentType "application/xml" -body $xml -Method POST


 Challenge now is to match the App-Names to the labels of installomator.