Files
MacAdmin/Jamf Pro/Scripts/jamf_policyCaller.sh
Zack T c9e6957f2d Code Improvements
General code improvements
2019-02-13 23:39:48 -07:00

40 lines
1.4 KiB
Bash

#!/bin/bash
###################################################################################################
# Script Name: jamf_policyCaller.sh
# By: Zack Thompson / Created: 11/30/2017
# Version: 1.0 / Updated: 11/30/2017 / By: ZT
#
# Description: This script uses JSS Parameters to run multiple custom triggers and/or Policy IDs.
# (JSS does not currently support multiple custom triggers in a single Policy, so this is a workaround for that.)
#
# Inspired by: @mm2270 - https://www.jamf.com/jamf-nation/feature-requests/2337/multiple-custom-events-per-policy
#
###################################################################################################
echo "***** policyCaller Process: START *****"
echo "Calling provided parameters..."
# If custom triggers are provided, loop through them.
if [[ -n $4 ]]; then
IFS=", " read customTriggers <<< $4
for customTrigger in $customTriggers; do
echo "Calling Policies that use the custom trigger: ${customTrigger}"
/usr/local/bin/jamf policy -trigger $customTrigger
done
fi
# If Policy IDs are provided, loop through them.
if [[ -n $5 ]]; then
IFS=", " read policyIDs <<< $5
for policyID in $policyIDs; do
echo "Calling Policy ID: ${policyID}"
/usr/local/bin/jamf policy -id $policyID
done
fi
echo "All policies have been processed."
echo "***** policyCaller Process: COMPLETE *****"
exit 0