Skip to main content
Question

Send mobile device command to mobile device smart group


Forum|alt.badge.img+3

Hello!

I need to send the update inventory command to my iPads to be able to check when they run out of battery.
Gladly i succeeded writing the test script to send it to one device, but i im looking for a way to send it to a whole group instead of doing it device per device.
This is the beautiful script.

1#!/bin/bash
2
3deviceID="59"
4
5# This works for single commands
6
7data="<mobile_device_command><general><command>UpdateInventory</command></general><mobile_devices><mobile_device><id>59</id></mobile_device></mobile_devices></mobile_device_command>"
8
9
10curl -fsku "${usr}:${pass}" -H "Content-Type: text/xml" "${jssdomain}/JSSResource/mobiledevicecommands/command" -d $data -X POST

Do you have any idea of how would it work for mobile devices smart groups?

Regards!

3 replies

Forum|alt.badge.img+3
  • New Contributor
  • 8 replies
  • May 9, 2019

I'll bump this since I actually have the same question.


Forum|alt.badge.img+20
  • Employee
  • 77 replies
  • May 9, 2019

To send this to multiple devices, you would just add additional instances of the mobile device ID to the existing XML array. For example:

1<mobile_device_command>
2 <general>
3 <command>UpdateInventory</command>
4 </general>
5 <mobile_devices>
6 <mobile_device>
7 <id>59</id>
8 </mobile_device>
9 <mobile_device>
10 <id>60</id>
11 </mobile_device>
12 </mobile_devices>
13</mobile_device_command>

Forum|alt.badge.img+1
  • New Contributor
  • 1 reply
  • April 14, 2020

@jose.gutierrez @evan684

Had the same problem and thought this might help you guys out

1#!/bin/sh
2jamfProURL="https://jamf.jamfcloud.com"
3jamfUser="jamf.admin"
4jamfPass="jamf1234"
5mobileDeviceGroupID="69"
6mobileDeviceCommand="SettingsEnableDataRoaming"
7
8##############################
9# Mobile Device Commands: #
10# UpdateInventory #
11# BlankPush #
12# SettingsEnableDataRoaming #
13# Full list: #
14# https://developer.jamf.com #
15##############################
16
17deviceIDs=( $( curl -s -u "$jamfUser":"$jamfPass" $jamfProURL/JSSResource/mobiledevicegroups/id/$mobileDeviceGroupID -H "Accept: application/xml" -X GET | xpath "//mobile_device_group/mobile_devices" | /usr/bin/perl -lne 'BEGIN{undef $/} while (/<id>(.*?)</id>/sg){print $1}' ) )
18
19for i in ${deviceIDs[@]}; do
20 echo "Sending $mobileDeviceCommand to Device ID: $i..."
21 /usr/bin/curl -sk -u "$jamfUser":"$jamfPass" -H "Content-Type: text/xml" -d "<?xml version="1.0" encoding="ISO-8859-1"?><mobile_device_command><general><command>$mobileDeviceCommand</command>></general><mobile_devices><mobile_device><id>$i</id></mobile_device></mobile_devices></mobile_device_command>" $jamfProURL/JSSResource/mobiledevicecommands/command/$mobileDeviceCommand -X POST > /dev/null
22 if [[ "$?" == "0" ]]; then
23 echo " $mobileDeviceCommand Command Processed Successfully"
24 else
25 echo " $mobileDeviceCommand Error Processing Command"
26 fi
27 echo ""
28done
29
30exit 0

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings