Run a Jamf script from the command line

Satchmo
New Contributor

Is there a Terminal command I can use to manually run, from Terminal, a Jamf script I've created?

1 ACCEPTED SOLUTION

easyedc
Valued Contributor II

+1 for throwing your script into a policy with a custom trigger and just running that via 

sudo jamf policy -event TRIGGERNAME

 There used to be a

sudo jamf runscript

 command, but it was clunky and hard to use. Looks like they deprecated it at some point and I didn't even notice. 

there's a decent thread on it here with some info on it, but it was clunky and hard to use. 

 % jamf help runscript

There is an error in your syntax.

     Error: runscript does not have any help.

Type "jamf help" for more information.

 

View solution in original post

6 REPLIES 6

sdagley
Esteemed Contributor II

@Satchmo No, there is not a mechanism to directly run a script in your JSS from the command line using the jamf binary. What you could do however is create a policy containing a Script payload with your script and scoped to all machines but with the only trigger being a custom event. That policy can be triggered from the command line using this syntax: sudo jamf policy -event TriggerNameHere

YanW
Contributor III

For just 1 or 2 machines, I create the script, use Jamf Remote, select the machine and the script, run and done. If for whatever reason you can't, then @sdagley is right, use the custom trigger.

sdagley
Esteemed Contributor II

@YanW I intentionally ignored Jamf Remote as an option because it's essentially useless for remote Macs connected via VPN, and Jamf has stated it will no longer be distributed in a future version of Jamf Pro (estimated removal date: May-July 2022)

teodle
Contributor II

the custom trigger method is your friend. Jamf Remote, RIP. Good riddance. It  was buggy as hell and more often than not would error on login...it would be useless for days and often require a bounce.   However, there were times when JAMF Remote was awesome for some tasks. It was cool to be able to run policies and commands/scripts on multiple machines in real time. Too bad JAMF never bothered fixing it. 

easyedc
Valued Contributor II

+1 for throwing your script into a policy with a custom trigger and just running that via 

sudo jamf policy -event TRIGGERNAME

 There used to be a

sudo jamf runscript

 command, but it was clunky and hard to use. Looks like they deprecated it at some point and I didn't even notice. 

there's a decent thread on it here with some info on it, but it was clunky and hard to use. 

 % jamf help runscript

There is an error in your syntax.

     Error: runscript does not have any help.

Type "jamf help" for more information.

 

sdagley
Esteemed Contributor II

@easyedc The runscript verb was for running a script already on the Mac, not from the JSS. It was deprecated because it ran the script with all of the PPPC allowances in place for the jamf binary, and that was a Very Bad Thing™.