Here is what I'm trying to do. When we do 3rd party patching, we have to do them in phases, alpha, beta and uat. We currently have 10 applications that we update monthly. For each application smart group, we have to add the group manually to each one. For example, this is what it would look like. On day one we add Alpha group and the next we add Beta group. I've messing with different scripts, but keep getting 404 error. It would be nice to run a script that would add the groups instead of going in to each one. Not sure if this even possible.
Here is what our update groups look like.
This is one of the scripts I was trying.
#!/bin/sh
# API login info
apiuser="xxx"
apipass="xxx"
jamfProURL="xxx"
# Smart group ID
SmartGroupID="120"
SmartGroupAPIURL="JSSResource/computergroups/id/${SmartGroupID}"
# XML header stuff
xmlHeader="<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"no\\"?>"
# Get the current smart group criteria
currentCriteria=$(curl -sSkiu ${apiuser}:${apipass} "${jamfProURL}/${SmartGroupAPIURL}" \\
-H "Accept: application/xml" \\
-X GET)
# Extract the current criteria priority
priority=$(echo "${currentCriteria}" | xmllint --xpath '/computer_group/smart_group_criteria/and/criterion/priority/text()' -)
# Increment the priority by 1
newPriority=$((priority+1))
# XML data to add "Smart Group" criteria with value "120" to smart group
apiData="<computer_group><id>${SmartGroupID}</id><name>Whatever the SmartGroupName Is</name><smart_group_criteria><and><criterion><name>Smart Group</name><priority>${newPriority}</priority><and_or>and</and_or><search_type>is</search_type><value>${SmartGroupID}</value></criterion></and></smart_group_criteria></computer_group>"
curl -sSkiu ${apiuser}:${apipass} "${jamfProURL}/${SmartGroupAPIURL}" \\
-H "Content-Type: text/xml" \\
-d "${xmlHeader}${apiData}" \\
-X PUT > /dev/null