Skip to main content

Hi

Am new to Jamf and still working things out.

Does anyone know how you can add multiple lab Mac's into a Static group.

We have 550 Mac's and moving them into different Static groups using a script would be great if possible.

Thanks

There are a few ways to do this. Do you have the ability to create a Smart group of your lab Macs? If so, you could have them all live in a Smart group, then export the list. And then use the MUT to import them into a Static group.


I have been doing this with the Jamf classic API

 

#!/bin/sh #API login info temp_nu="Temp Username" apiuser=$(echo $temp_nu | openssl base64 -d) temp_np="Temp Password" apipass=$(echo $temp_np | openssl base64 -d) jamfProURL="https://ORG.jamfcloud.com" #Grab serial number and OS Version of computer SerialNumber=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}') macOSVersion=$(sw_vers -productVersion) #update group with Group ID you want GroupID="[ID Number]" apiURL="JSSResource/computergroups/id/${GroupID}" #Check macOS Major CheckIt=$(echo $macOSVersion | cut -d . -f 1) #Add Computer to group based on macOS Version if [[ "$CheckIt" -ge "11" ]] then #macOS 11 update to xpath requires "-e" in front of xml query GroupName=$(curl -H "Accept: application/xml" -sfku "${apiuser}:${apipass}" -X GET "${jamfProURL}/${apiURL}" | xpath -e '/computer_group/name/text()' 2>/dev/null) else GroupName=$(curl -H "Accept: application/xml" -sfku "${apiuser}:${apipass}" -X GET "${jamfProURL}/${apiURL}" | xpath '/computer_group/name/text()' 2>/dev/null) fi #XML header stuff xmlHeader="<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>" #API command to add the serial number to the Static Group apiData="<computer_group><id>${GroupID}</id><name>${GroupName}</name><computer_additions><computer><serial_number>$SerialNumber</serial_number></computer></computer_additions></computer_group>" #Mix it all together curl -sSkiu ${apiuser}:${apipass} "${jamfProURL}/${apiURL}" \\ -H "Content-Type: text/xml" \\ -d "${xmlHeader}${apiData}" \\ -X PUT > /dev/null #Run an Inventory Update sudo /usr/local/jamf/bin/jamf recon sleep 5 exit 0

I have been doing this with the Jamf classic API

 

#!/bin/sh #API login info temp_nu="Temp Username" apiuser=$(echo $temp_nu | openssl base64 -d) temp_np="Temp Password" apipass=$(echo $temp_np | openssl base64 -d) jamfProURL="https://ORG.jamfcloud.com" #Grab serial number and OS Version of computer SerialNumber=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}') macOSVersion=$(sw_vers -productVersion) #update group with Group ID you want GroupID="[ID Number]" apiURL="JSSResource/computergroups/id/${GroupID}" #Check macOS Major CheckIt=$(echo $macOSVersion | cut -d . -f 1) #Add Computer to group based on macOS Version if [[ "$CheckIt" -ge "11" ]] then #macOS 11 update to xpath requires "-e" in front of xml query GroupName=$(curl -H "Accept: application/xml" -sfku "${apiuser}:${apipass}" -X GET "${jamfProURL}/${apiURL}" | xpath -e '/computer_group/name/text()' 2>/dev/null) else GroupName=$(curl -H "Accept: application/xml" -sfku "${apiuser}:${apipass}" -X GET "${jamfProURL}/${apiURL}" | xpath '/computer_group/name/text()' 2>/dev/null) fi #XML header stuff xmlHeader="<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>" #API command to add the serial number to the Static Group apiData="<computer_group><id>${GroupID}</id><name>${GroupName}</name><computer_additions><computer><serial_number>$SerialNumber</serial_number></computer></computer_additions></computer_group>" #Mix it all together curl -sSkiu ${apiuser}:${apipass} "${jamfProURL}/${apiURL}" \\ -H "Content-Type: text/xml" \\ -d "${xmlHeader}${apiData}" \\ -X PUT > /dev/null #Run an Inventory Update sudo /usr/local/jamf/bin/jamf recon sleep 5 exit 0

OP said they are new to Jamf. I didn't want to throw a script at them that accesses the API. Mike M. has a number of posts on JamfNation about doing this with API access. I'd still like to see this functionality built into Jamf Pro. Allowing us to migrate groups from Smart --> Static (and perhaps even in the reverse) within the Jamf Pro UI would be super useful.


OP said they are new to Jamf. I didn't want to throw a script at them that accesses the API. Mike M. has a number of posts on JamfNation about doing this with API access. I'd still like to see this functionality built into Jamf Pro. Allowing us to migrate groups from Smart --> Static (and perhaps even in the reverse) within the Jamf Pro UI would be super useful.


Fair point, I figured I would mention it since it is brought up every once in a while. A GUI method would be nice to have for sure.


Thanks for the information, will look into the smart group options before trying to tackle the script.

Thanks


I'm not sure how helpful it will be, but a long while ago I built a script that can take an existing Smart Computer Group and convert it into a Static Computer Group using the API. But I last updated it in 2015, so it's close to 6 years old by now. It probably doesn't work as is anymore.

If anyone is interested, I can see about refreshing it. But truthfully, the MUT as mentioned by @damienbarrett is a great and easy to use application that is worth looking at. It does a lot of things, not just one thing like a one off script.


I am also using  "The MUT" 

Jamf Admins can  make mass changes to static groups, scope of prestage enrollments, make mass updates to attributes (such as username, asset tag, or extension attribute) of their devices and users in Jamf

https://github.com/mike-levenick/mut

https://github.com/mike-levenick/mut#static-group-updates


I suggest using the MUT unless you want to make your own API. 


There are a few ways to do this. Do you have the ability to create a Smart group of your lab Macs? If so, you could have them all live in a Smart group, then export the list. And then use the MUT to import them into a Static group.


Where can I find the MUT tool to import to Static?


Where can I find the MUT tool to import to Static?


https://github.com/mike-levenick/mut

https://github.com/mike-levenick/mut#static-group-updates