Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. Join us in person at the ninth annual Jamf Nation User Conference (JNUC) this November for three days of learning, laughter and IT love.

Trying to add an exclusion to an Mobile Device App Assignment via the API

We were able to use the script found here created by @bumbletech that creates a csv of all the apps in our environment that are 32-bit only and my goal is to exclude our iOS 11 devices from these groups.

We found if you have an iOS 11 devices in the target group for a 32-bit only app the JSS continually tries to install the app on the iOS 11 devices.

I was able to piece together this command, which is my attempt to add an exclusion group to the 32-bit only apps:

#!/bin/bash
jss_user="username"
jss_password="password"
jss_url="https://jssurl.company.com:8443"
app_id="3435"
exclusion_group="1588"

curl -sS -k -i "${jss_url}"/JSSResource/mobiledeviceapplications/id/$app_id --user "${jss_user}:${jss_password}" -X PUT -H "Content-Type: text/xml" -d "<mobile_device_application><scope><exclusions><mobile_device_groups><mobile_device_group><id>$exclusion_group</id></mobile_device_group></mobile_device_groups></exclusions></scope></mobile_device_application>"

The problem with it is that it clears out the target group, which is not good. I was hoping someone knew of a way I can add an exclusion group without affecting the existing target group to the app assignment?

Once this is working I was going to create a loop in the script that loops through all the apps identified in that csv.

Thanks

Like Comment
Order by:
SOLVED Posted: by bburdeaux

I've seen this quirk pop up before, but have never seen anyone present a solution to the issue. It ends up being a sort of triangle of not-working-right; adding targets removes limitations, adding limitations removes exclusions, and adding exclusions removes targets.

This can be done in mysql, but inserting directly into mysql is never ideal and I always recommend to try very hard to use the api before turning to mysql. With that disclaimer out of the way, here's an example query using your app and group ids.

insert into mobile_device_app_deployment 
(mobile_device_app_id, target_type, target_id, exclusion) 
values (3435, 25, 1588, 1);

*note: a target_type of 25 indicates a mobile device group. If you ever decide to use a similar query with a different target type, you'll need to find the number that corresponds with that target type.

Like
SOLVED Posted: by kerouak

@bburdeaux

How di d you find the target_type??

I'm looking to exclude some smart groups from managed_preference_profile_deployment??

ta

Like
SOLVED Posted: by bburdeaux

@kerouak

I just compared the GUI scope of a few mobile device apps to the entries in mobile_device_app_deployment to figure it out. I'll give you the list of the target types I know below.

21 = Mobile Device
25 = Mobile Device Group
102 = All Mobile Devices

1 = Computer
7 = Computer Group
101 = All Computers

53 = User
54 = User Group

Like
SOLVED Posted: by kerouak

Cheers, ive been doin the same with mcx.. just thought there cld be an easier way.
Thanks anyways

Like
SOLVED Posted: by exit0hero

I can't find a script handy, but have done it before in the past with single line loops.

Using the API the XML will need to be modified and can not address bits and pieces.

If the scope is 5 smart groups 6 users and 2 exclusions and looking to append an exclusion, the curl command will need to tell that object that the scope should be 5 smart groups, 6 users and 3 exclusions.

Like

Jamf wants to hear your feedback around Peripherals and Jamf Connect settings configuration