Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. Join us in person at the ninth annual Jamf Nation User Conference (JNUC) this November for three days of learning, laughter and IT love.

Use scripts multiple times in a policy

It would be great to be able to use the same script multiple times in a single policy. An example would be a generic script with variables passed from the JSS to perform an action such as an install or configuration. At the moment the only way to do this would be to chain policies together or with a script calling to multiple policies.

Comment
Order by:

Posted: by jimlee

Can you give a scenario when this would be used? Sorry trying to understand what you mean before I vote.

Like

Posted: by bentoms

Here's an example: http://macmule.com/2013/10/22/how-to-create-a-microsoft-remote-desktop-8-connection/

If the script could be used more than once, then more servers could be defined.

Like

Posted: by winningham.2

@jimlee
I have a script that interacts with launchctl to unload/load launchd. So here is an example:
I have a package for Chrome that needs to first unload a LaunchDaemon for the Google Updater, then install the package, and finally load the new version of the LaunchDaemon into launchctl. We package all of our packages into DMGs, as per policy (but I can also explain why, later, if this is an issue for someone).

The script is simple enough in that param4 can be passed a switch along with a path-to-file to either unload (-u), remove (-r), load (-l), or display usage (-h) to launchctl. Therefore, one generically worded script can be ran once, before the install, to unload the launch daemon, and then after the install to load the new daemon. If I install multiple apps per policy, I may need more than one version of this script to be performed. However, JAMF does not like this and would rather me write many specified version of the same script just to run what I describe here above.

It seems silly that JAMF is not smart enough to run multiple versions of the same script and this should have been implemented eons ago. After all, the JSS is rather like its own object oriented environment and what if I could only run the same snippet ONCE in my code. Honestly, this just needs to be done.

Like

Posted: by mm2270

I can understand the reason why most objects in the JSS can't be added/enabled more than once in the same policy. For example. things like Computers/mobile devices, or packages. Its hard to imagine a use case where you would want to add the same Mac into scope more than once, or install the same package more than once in a single policy. (though I'm sure someone could come up with a case) So its done this way to prevent you from making the mistake of adding it more than once and causing havoc.

That said, I would agree that Scripts should be treated differently than other objects because they have more utility. The examples above of using a simple parameter assignment to change some aspect(s) of the script is a perfect example. Since packages don't have this ability, it makes sense not to be able to add them more than once, but scripts shouldn't be subject to that rule.

If JAMF is still concerned that someone may accidentally add the same script twice or thrice, then make it so if its already added, when you choose to add it again it pops up a simple confirmation dialog:

The script "my_script.sh" was already added to this policy.
Are you sure you want to add it again?

[ No ]         [ Yes ]

That would sufficiently solve the issue. If it was truly an accidental second add, you can click No, if it was intentional, click Yes.

Like

Posted: by willpolley

Just ran into this problem as well... using a script to change user account pictures of accounts.

This seems pretty basic. And disappointing.

Like

Posted: by jamesdurler

its useful where you've made an effort to keep the number of scripts in your JSS down by generalising a script as much as possible through Parameters.

I have an install script for Maya which takes the installer pkg name as parameter 4. If i want to deploy multiple versions of Autodesk Maya I have to create seperate policies as the JSS doesn't seem to allow the same script twice

Like

Posted: by grahamrpugh

I also need this for printer installations. See this gist for a useful printer installation template script that takes parameters:
https://gist.github.com/grahampugh/30df87d5dcfd313db8d2c92d132f857d

Unfortunately if I want a policy that installs multiple printers, I need to clone the script so that I can add it multiple times. This could be easily scripted in the JSS code to add a numerical value to the end of the script identifier.

Like

Posted: by ajacks88

Didnt see this before i posted mine. Take a look at mine for a good use case for this.

Like

Posted: by mario

Agreed that this would be a nice addition. I've written a script to install a command-line binary as an argument (and have multiple binaries to install in this manner), but since I can't have multiple instances of the same script in a policy, I've had to create multiple separately-managed policies instead, each running a single script with a different argument. Seems like consolidating all the scripts in one policy would make this a simpler setup to manage.

Like

Posted: by pitcherj

Would also love to see this, entered a support request because I thought I'd uncovered a bug - I have a generic script that runs a pkg-based installer with the "-allowUntrusted" flag (several older app installers are signed with expired certs).

Putting multiple copies of this script in the same policy duplicates the parameters from the first copy of the script to the second, etc.

I had to create multiple copies of the script in the script repository to permit adding multiple instances of it in a single policy.

Like

Posted: by pvcit

Ditto, just ran into this issue and was surprised JAMF is like this in 2019. I started using a single script with parameters and was wondering why when I added a second script it just copied the settings from the first. Sad.

Like

Posted: by barnesaw

Why would anyone want to possibly install more than one printer in a single policy? I mean without using the absolute garbage fire that is "printers" in the jamf workflow.

Idiots.

Like