So running this to add and exclusion to a manged preference:
>>
!/bin/bash
Set the API credentials and JSS URL here. API account must have permissions to edit policies
apiUser="apifulluser"
apiPass="iovobinospoisigehecm"
jssURL="https://jss.arts.ac.uk:8443"
Edit this array to include the actual policy JSS IDs
POLICYIDS=(362)
function update_Managed_Preference ()
{
echo "Editing Managed Preference ID: $ID"
Generate a temp xml file with the new custom trigger name
cat << EOD > /tmp/$ID.xml
<managed_preference_profile><scope>
<exclusions>
<computer_groups/>
<computer_group>
<id>599</id>
<name>OS Version: All 10.13</name>
<is_smart>true</is_smart>
<site>
<id>-1</id>
<name>None</name>
</site>
</computer_group>
</exclusions>
</scope></managed_preference_profile>
EOD
Upload the new policy data to update the policy
/usr/bin/curl -sfku "${apiUser}:${apiPass}" "${jssURL}/JSSResource/managedpreferenceprofiles/id/$ID" -T /tmp/$ID.xml -X PUT
Check the exit status of the PUT command
if [ $? == 0 ]; then
echo -e "
Managed Preference $ID edited successfully"
rm /tmp/$ID.xml
else
echo -e "
Managed Preference $ID could not be edited"
rm /tmp/$ID.xml
fi
}
Loop over array, running the above function on each ID
while read ID; do
update_Managed_Preference
done < <(printf '%s
' "${POLICYIDS[@]}")
The output of the script:
Editing Managed Preference ID: 362
<?xml version="1.0" encoding="UTF-8"?><managed_preference_profile><id>362</id></managed_preference_profile>
Managed Preference 362 edited successfully
On checking back with the JSS, I can see no addition to the exclusion...
Anyone??