Need help with making the script work for chaning computer Status tag in General

EK2000
New Contributor

I am fairly new in scripting and I am having trouble modifying a script that will successfully change the status tag of computers in a certain smart group.

The status tag which is in the General and you have multiple drop down option (like Active, Retired, disposable, etc) options is created in EA.

I can manually change it by going in the computer in general press edit and from the Status drop menu select what is the new status. I need to make the script do this for me.

 

 

#!/bin/bash
# ——————————— Changes Site ———————————
apiURL="https://domain.jamfcloud.com"
apiUser="user"
apiPass="password"
newStatus="Disposed"

# ——————————— Getting the serial ———————————
computerserial="$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}')"


#Change the Site
echo "<computer><general><status><value>$newStatus</value></status></general></computer>" | curl -X PUT -fku $apiUser:$apiPass -d @- $apiURL/JSSResource/computers/serialnumber/$computerserial/subset/general -H "Content-Type: application/xml"

 

 

This doesn't work, I did try few variations but it seems I am missing something but I don't know what.

2 ACCEPTED SOLUTIONS

I was checking the error logs and I had 401, weirdly the API account had the appropriate rights assigned but after I selected full rights just to test if that was the reason it managed to change it.

I need to mention I did modify the script to to edit in extension attribute like in the link you provided.

Cheers!

View solution in original post

2 REPLIES 2

vinu_thankachan
Contributor

I was checking the error logs and I had 401, weirdly the API account had the appropriate rights assigned but after I selected full rights just to test if that was the reason it managed to change it.

I need to mention I did modify the script to to edit in extension attribute like in the link you provided.

Cheers!