@jchurch
These are good starting points
https://jamfnation.jamfsoftware.com/discussion.html?id=10188
http://macbrained.org/the-jss-rest-api-for-everyone/
https://bryson3gps.wordpress.com/the-unofficial-jss-api-docs/
so i got my script to mostly work. I'm using an extension attribute and a smart group. it works fine if the serial number is in the script, i want it to popup and ask the user to enter the serial number. here's what i have so far.
#!/bin/sh
YourAPIUsername="username"
YourAPIPassword="password"
jssurl="jssurl"
serialnumber="<manual input>"
FIX="/path/to/FIX.xml"
DONE="/path/to/DONE.xml"
curl -k -v -u $YourAPIUsername:$YourAPIPassword $jssurl/JSSResource/mobiledevices/serialnumber/$serialnumber/subset/extensionattributes -T "$FIX" -X PUT
sleep 3
curl -k -v -u $YourAPIUsername:$YourAPIPassword $jssurl/JSSResource/mobiledevices/serialnumber/$serialnumber/subset/extensionattributes -T "$DONE" -X PUT
these are my xml files:
DONE.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mobile_device>
<extension_attributes> <attribute> <name>WiFi Fix</name> <type>String</type> <value>DONE</value> </attribute>
</extension_attributes>
</mobile_device>
FIX.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mobile_device>
<extension_attributes> <attribute> <name>WiFi Fix</name> <type>String</type> <value>FIX</value> </attribute>
</extension_attributes>
</mobile_device>
You could try using an Applescript call to ask for input, but its not always 100% reliable when run from policies out of the JSS. Generally, when run from Self Service they should work. Its more an issue when run from a recurring trigger for example.
Example:
#!/bin/sh
SERIAL=$(/usr/bin/osascript << EOF
tell application "System Events"
try
set Serial to text returned of (display dialog "Enter a serial number" buttons {"Cancel", "Enter"} default button 2 default answer "")
end try
end tell
EOF)
if [ "$SERIAL" != "" ]; then
echo "User input serial: $SERIAL"
else
echo "User canceled. Exiting"
exit 0
fi
worked like a charm. thanks