Skip to main content
Question

Jamf Moving Multiple Computers into Static Group


Forum|alt.badge.img+3

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

10 replies

damienbarrett
Forum|alt.badge.img+19
  • Honored Contributor
  • 343 replies
  • July 28, 2021

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.


Forum|alt.badge.img+9
  • Contributor
  • 137 replies
  • July 28, 2021

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

damienbarrett
Forum|alt.badge.img+19
  • Honored Contributor
  • 343 replies
  • July 28, 2021
nelsoni wrote:

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.


Forum|alt.badge.img+9
  • Contributor
  • 137 replies
  • July 28, 2021
damienbarrett wrote:

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.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 2 replies
  • July 28, 2021

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

Thanks


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • July 28, 2021

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.


Forum|alt.badge.img+7

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


bwoods
Forum|alt.badge.img+14
  • Honored Contributor
  • 473 replies
  • July 29, 2021

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


Forum|alt.badge.img+10
  • Valued Contributor
  • 134 replies
  • July 30, 2021
damienbarrett wrote:

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?


Forum|alt.badge.img+7
sgiesbrecht wrote:

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings