I am attempting to set (or more accurately clear) recovery lock on an M1 Macbook Air using bash. I work for a school district but we are using Jamf Pro
We have had an issue where several hundred of our fleet have been (seemingly) randomly getting set into Recovery Lock. Some after initial log in. Others after our end users have had the device for a few hours or days. While the larger issue of what's triggering it is being investigated, I was trying to help speed up the process of getting these devices back into our users hands and clear the recovery lock code (and then set another one) so they could get back in.
We have a little under 10K M1 MacBook Airs and I was able to obtain the management ID (as detailed here) for the devices I want to do this too. I am new to scripting but was able to work my way through obtaining a bearer token and parsing the different pages to find the device in question (using jq to pull the relevant management ID).
I've looked at every sample script I could find related to Recovery Lock but all of them are ending up with various errors. Sometimes it's a 401 (which I've even gotten when trying with an account with full admin access, though ultimately I'd like to use a single purpose account for this). Other times I've gotten a 415 and it's said something along the lines of the curl command wasn't formatted properly, though I was using the same one from the website (as far as I know).
I am 100% ready to believe it's operator error. Like I said I'm new to scripting. Outside Shortcuts programming in general is not something I have experience with. I've actually tried in shortcuts but am getting the same results. Shortcuts is how I initially figured out the management ID before moving that to bash as well.
Here is my latest attempts at what I have been sending. Any advise would be greatly appreciated.
curl --location --request POST 'https://myDomain.jamfcloud.com/api/preview/mdm/commands' \\
--header 'Authorization: Bearer $bearerToken' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"clientData": [
{
"managementId": "'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'",
"clientType": "COMPUTER"
}
],
"commandData": {
"commandType": "SET_RECOVERY_LOCK",
"newPassword": "NewPassword",
}
}'