Skip to main content
Jamf Nation, hosted by Jamf, is a dynamic and knowledgeable community of Apple-focused IT admins and Jamf Pro users. Join us in person, in October, for the annual Jamf Nation User Conference (JNUC) to discover new and better ways to manage Apple devices.

Write a script they! Run several policy id #s?

I need to create a script, but I haven't the faintest idea about creating scripts. I am inept at programming.

What I need is a script that will run these policy id #s in sequence

jamf policy -id 173
jamf policy -id 174
jamf policy -id 171
jamf policy -id 172

Can anyone help me with this animal?

Like Comment
CCA Badge
SOLVED Posted: 3/20/17 at 1:41 PM by mm2270

Hi @mccallister! Interestingly enough, what you posted is basically almost all there! :)

All you would need to do, in a very simplistic fashion, is put a shebang at the top of what you have. For example:

#!/bin/sh

jamf policy -id 173
jamf policy -id 174
jamf policy -id 171
jamf policy -id 172

That first line #!/bin/sh is what tells it to be a script, so to speak. A "shell" script specifically.

Take the above and copy/paste into a plain text file. The "plain" part is important. Shell scripts do NOT like any special formatting or odd carriage returns, etc. Best to use something like the free TextWrangler or some other plain text file editor. Try to avoid TextEdit. Despite its name, it's more of a rich text editor and likes to auto format things like those regular dashes into em dashes, which fouls up the script.

Even better would be to create the script directly in your JSS and bypass a file, unless you need to test it locally first. The JSS won't try to add in any crazy formatting to the script.

As you begin to explore scripting, you can add in more to your scripts. Like echo commands to indicate which policy is being run by the script and other stuff. But the above will get you what you need as a start.
Just make sure none of those policies are doing something like rebooting the Mac since it would interrupt the flow of the script and not allow all of them to run.

Like
SOLVED Posted: 3/20/17 at 2:04 PM by mccallister

Thank you! I created the script directly in JSS and it works exactly like I wanted.

Like