Scheduled Restart for iPad

nayres
New Contributor

I saw a previous discussion that glanced over this topic. They mentioned that it would be possible using the API, but I was hoping that someone may be able to further elaborate on that.

I am looking to restart my buildings iPads at a specific time each day.

Thank you,

1 REPLY 1

ryan_ball
Valued Contributor

@nayres This script below that I posted for somebody here yesterday will restart an iPad, but only if it is on and connected to Wi-Fi, otherwise the command would be sitting as pending until the device is connected to Wi-Fi or woken up. You could easily add in a for loop to send the command to a list of devices based on a smart group or advanced search, but if the devices were asleep then whenever a user comes in and wakes the device, it would restart right then and there. So I don't think you can do exactly what you want to do.

#!/bin/bash

# https://www.jamf.com/jamf-nation/discussions/30751/api-script-for-ipad-restart

jssURL=$(defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url | sed s'/.$//')

apiUser="user_here"
apiPass='password_here'
deviceID="device_ID_here"

data="<mobile_device_command><general><command>RestartDevice</command></general><mobile_devices><mobile_device><id>${deviceID}</id></mobile_device></mobile_devices></mobile_device_command>"

echo "Attempting to send a RestartDevice command to Mobile Device with ID: $deviceID"
curl -ksu "$apiUser:$apiPass" -H "Content-Type: text/xml" "$jssURL/JSSResource/mobiledevicecommands/command" -d $data -X POST

exit 0