Posted on 09-19-2024 08:38 AM
A few months ago, I was able to use the Jamf API to obtain a computer's room assignment. I need to now get the computer's site. I don't care if I can only obtain the site ID or its actual name. I need this so I can avoid creating a separate installer package for the different regions in my company. I want the install script to first obtain the computer's site assignment and then choose the appropriate customization for each region. I thought this would be similar to getting the room assignment but apparently it's not. Does anyone know the correct way to do this?
Solved! Go to Solution.
Posted on 09-20-2024 06:44 AM
Interesting. I have used $EMAIL and $COMPUTERNAME before but not $SITEID. This will be useful. I did figure out how to query the computer's site assignment using the API. One of my coworkers helped me nail it. I added this variable to my script along with a function that handles the Jamf Pro API authentication. This variable returns the site name. I used this variable with a case statement to run the appropriate tagging command after the software is installed. So far, it's working great.
site=$(curl -s -H "Accept: text/xml" -H "Authorization: Bearer ${token}" ${jamfProURL}/JSSResource/computers/serialnumber/"$serialNumber" | xmllint --xpath 'string (//computer/general/site/name)' -)
Posted on 09-20-2024 04:30 AM
You don't need to use the API.
You can get the site using Configuration Profile Variables, see here:
You can the pull that key using a script or EA
Posted on 09-20-2024 06:44 AM
Interesting. I have used $EMAIL and $COMPUTERNAME before but not $SITEID. This will be useful. I did figure out how to query the computer's site assignment using the API. One of my coworkers helped me nail it. I added this variable to my script along with a function that handles the Jamf Pro API authentication. This variable returns the site name. I used this variable with a case statement to run the appropriate tagging command after the software is installed. So far, it's working great.
site=$(curl -s -H "Accept: text/xml" -H "Authorization: Bearer ${token}" ${jamfProURL}/JSSResource/computers/serialnumber/"$serialNumber" | xmllint --xpath 'string (//computer/general/site/name)' -)