Reference PreStage Enrollment or Smart Group via Bash Script?

jalbert
Contributor

Is it possible? I would like to run a section of a script if the computer is either a member of a smart group or prestage enrollment (PSE), or maybe do something else if it is a member of another group or PSE.

Trying to automate my automated setups depending on the school the device belongs to.

1 REPLY 1

Tribruin
Valued Contributor II

So you want to have a script that run mulitple commands based on what Smart Group they belong too? So..

If $computer in "SG1"; then run $command1
if $computer in "SG2"; then run $command2

My suggestion here is to break your script in to multiple policies and scope each policy to the appropriate smart groups. Then create a master script that runs each policy by customEvent.

Policy1 (Scoped to SG1 - custom trigger Policy1): run script ($command1)

Policy2 (Scoped to SG2 - custom trigger Policy2): run script ($command2)

Policy3 (Scoped to all computers, any trigger): jamf policy -event Policy1 jamf policy -event Policy2

When policy3 runs, it will try and run Policy1 and Policy2. If a computer is in scope the assoicated policy will run, otherwise it will be skipped. I use this a lot in enrollment policies so that I can just include and exclude policies as necessary, with out having to change my script.