Multiple processes with one script

nick_conway
New Contributor II

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!

1 ACCEPTED SOLUTION

Tribruin
Valued Contributor II

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 solution in original post

2 REPLIES 2

Tribruin
Valued Contributor II

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.

nick_conway
New Contributor II

Worked like a charm! Thank you!