Launching Policy from Bash Script

db65681
New Contributor

Hi,

We've got a few printers in our organization that we initially put in Self Service that were installed by most of our employees. Recently, some settings needed to be changed for the printers, so that they would go through a network share instead of a direct IP address. I've updated the printer in the policy (for Self Service), but now need a way to automate a remove and reinstall of the printers on the user's computers. What I've got so far is a really simple bash script to remove the printers:

lpadmin -x My_Printer1
lpadmin -x My_Printer2
lpadmin -x My_Printer3

My question is, is there a bash command I can append to the end of this script to launch the policy to install the printer again from Self Service? I'd be willing to try another approach if anyone was kind enough to offer one.

Thanks in advance.

1 ACCEPTED SOLUTION

bvrooman
Valued Contributor

You can trigger policies from a script in a number of ways. They're all based on the 'jamf policy' command.

If you want to trigger one policy specifically (keep in mind it must be scoped to the computer and not disabled due to a date/time or non-Ongoing execution setting):

jamf policy -id ##

If you set a custom trigger and want to run all of the policies with that trigger configured:

jamf policy -trigger someTriggerHere

Run "sudo jamf help policy" in Terminal for specifics.

View solution in original post

4 REPLIES 4

bvrooman
Valued Contributor

You can trigger policies from a script in a number of ways. They're all based on the 'jamf policy' command.

If you want to trigger one policy specifically (keep in mind it must be scoped to the computer and not disabled due to a date/time or non-Ongoing execution setting):

jamf policy -id ##

If you set a custom trigger and want to run all of the policies with that trigger configured:

jamf policy -trigger someTriggerHere

Run "sudo jamf help policy" in Terminal for specifics.

stevewood
Honored Contributor II
Honored Contributor II

@bagdasd if you're already running a script to remove the printer(s), why not just let the script do the add as well instead of calling a JAMF policy?

db65681
New Contributor

@bvrooman Thank you! You rock man!

db65681
New Contributor

@stevewood Hi Steve, thanks for the reply. That's also a good option, but it seems like launching the policy would be easier than specifying all of the cups settings for 3 printers in a script.