Posted on 07-28-2021 07:12 AM
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
Posted on 07-28-2021 07:22 AM
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.
Posted on 07-30-2021 12:29 PM
Where can I find the MUT tool to import to Static?
Posted on 07-30-2021 12:33 PM
Posted on 07-28-2021 07:31 AM
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
Posted on 07-28-2021 07:36 AM
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.
Posted on 07-28-2021 07:38 AM
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.
Posted on 07-28-2021 07:55 AM
Thanks for the information, will look into the smart group options before trying to tackle the script.
Thanks
Posted on 07-28-2021 08:49 AM
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.
07-28-2021 11:57 AM - edited 07-28-2021 12:00 PM
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
07-28-2021 07:58 PM - edited 07-28-2021 07:58 PM
I suggest using the MUT unless you want to make your own API.