Skip to main content
Question

Reference PreStage Enrollment or Smart Group via Bash Script?

  • June 9, 2021
  • 1 reply
  • 0 views

Forum|alt.badge.img+9

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

Forum|alt.badge.img+19
  • Honored Contributor
  • 582 replies
  • June 10, 2021

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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings