Skip to main content
Solved

Multiple processes with one script


Forum|alt.badge.img+3

I'm not sure if this has been covered before but my searches didn't bring up anything so im giving it a shot.

I am looking for a way to run multiple commands with one trigger. Essentially i'd like to run something like

sudo jamf policy -event runImaging

and have it kick off, in order:

sudo jamf flushpolicyhistory
sudo jamf policy -event login
sudo jamf policy
sudo jamf recon

Is this something that is possible? Any assistance is greatly appreciated!

Best answer by Tribruin

There are a couple of ways to do that.

One is to just create a script that runs each of those commands in succession and then create a policy that runs that script with the custom trigger runImaging. The only change is that you would not use the sudo command in front of each of the command. Scripts run from a policy are already running as root.

The only option is to create four policies, each using the execute process command in the Files and Processes payload. (Technically jamf recon is just an Inventory Collection, so you can use the standard Update Inventory under maintenance.). You would then name each policy in order you them to run (1. FlushPolcyHistory, 2. Policy Login, etc.) and then assign the same custom trigger to each policy. Jamf will run the policies in alphabetical (or numeric in the case) order.

In your case, I think a script is the quickest. The one reason I like use the second option is that I can specify multiple policies to the same trigger and then use scope to determine whether a policy runs or not. For example, if I had a first time setup policy with a custom trigger, I could create a policy that installs Office and scope it to every computer and another policy for VPN software and only scope it to laptops. When that setup custom trigger is run Jamf will only run the policies that are scoped to that computer.

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+19
  • Honored Contributor
  • 582 replies
  • Answer
  • December 2, 2020

There are a couple of ways to do that.

One is to just create a script that runs each of those commands in succession and then create a policy that runs that script with the custom trigger runImaging. The only change is that you would not use the sudo command in front of each of the command. Scripts run from a policy are already running as root.

The only option is to create four policies, each using the execute process command in the Files and Processes payload. (Technically jamf recon is just an Inventory Collection, so you can use the standard Update Inventory under maintenance.). You would then name each policy in order you them to run (1. FlushPolcyHistory, 2. Policy Login, etc.) and then assign the same custom trigger to each policy. Jamf will run the policies in alphabetical (or numeric in the case) order.

In your case, I think a script is the quickest. The one reason I like use the second option is that I can specify multiple policies to the same trigger and then use scope to determine whether a policy runs or not. For example, if I had a first time setup policy with a custom trigger, I could create a policy that installs Office and scope it to every computer and another policy for VPN software and only scope it to laptops. When that setup custom trigger is run Jamf will only run the policies that are scoped to that computer.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • December 4, 2020

Worked like a charm! Thank you!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings