I wrote this many years ago when I worked at jamf as a POC for a site chooser script, this may help you in the right direction. Just tested it on 10.14.6 and it still runs
#!/bin/bash
# set multiple site enrollment via one quick add package
getSite() {
theSite=$(osascript <<AppleScript
set mySites to {"Minneapolis", "Cupertino", "New York", "Hong Kong", "Amsterdam", "Eau Claire"}
set selectedSite to {choose from list mySites}
AppleScript
echo "${theSite}"
)
}
getSite
echo "${theSite}"
# now select invitation codes
# put site names with spaces in single quotes
case ${theSite} in
Minneapolis)
invCode='1234567890';;
Cupertino)
invCode='0987654321';;
'New York')
invCode='6789012345';;
'Hong Kong')
invCode='8901234567';;
Amsterdam)
invCode='3456789012';;
'Eau Claire')
invCode='4567890123';;
esac
echo "put your enrollment command here with code ${invCode}"
exit 0
Thanks @tlarkin I'll take a look at this.
QQ - say I pick Amsterdam, if I want to run a command like:
jamf policy -event <triggerName>
Can I just replace the : invCode='3456789012';; part??
Cheers,
Steve
@sslavieroGSMA correct, you can put any unix command in there
@tlarkin Does this look correct??
#!/bin/bash
# set multiple site enrollment via one quick add package
getSite() {
theSite=$(osascript <<AppleScript
set mySites to {"London", "Atlanta", "Hong Kong"}
set selectedSite to {choose from list mySites}
AppleScript
echo "${theSite}"
)
}
getSite
echo "${theSite}"
# now select invitation codes
# put site names with spaces in single quotes
case ${theSite} in
London)
jamf policy -event rescuelondon;;
Atlanta)
jamf policy -event rescueatlanta;;
'Hong Kong')
jamf policy -event rescuehongkong;;
esac
exit 0
The idea is to select the location and it will go off and run the select Policy via it's trigger.
I pop this script in a Policy, which I can use during deployment > which in turn runs the policy I want to install the correct software.
@sslavieroGSMA
It looks like it might work, have you tested it? That script I gave you I wrote really fast for either a POC or some sort of training I cannot remember as it was easily 6+ years ago at this point. You just need to test and tweak for your needs. I also had some redundant echo
commands in there when I was writing this. This is literally a 5 minute job, not much debugging and definitely no code tidy up at all. So, just make sure you keep on testing it out.
I wrote this many years ago when I worked at jamf as a POC for a site chooser script, this may help you in the right direction. Just tested it on 10.14.6 and it still runs
#!/bin/bash
# set multiple site enrollment via one quick add package
getSite() {
theSite=$(osascript <<AppleScript
set mySites to {"Minneapolis", "Cupertino", "New York", "Hong Kong", "Amsterdam", "Eau Claire"}
set selectedSite to {choose from list mySites}
AppleScript
echo "${theSite}"
)
}
getSite
echo "${theSite}"
# now select invitation codes
# put site names with spaces in single quotes
case ${theSite} in
Minneapolis)
invCode='1234567890';;
Cupertino)
invCode='0987654321';;
'New York')
invCode='6789012345';;
'Hong Kong')
invCode='8901234567';;
Amsterdam)
invCode='3456789012';;
'Eau Claire')
invCode='4567890123';;
esac
echo "put your enrollment command here with code ${invCode}"
exit 0
This helped me. Thanks!
I wrote this many years ago when I worked at jamf as a POC for a site chooser script, this may help you in the right direction. Just tested it on 10.14.6 and it still runs
#!/bin/bash
# set multiple site enrollment via one quick add package
getSite() {
theSite=$(osascript <<AppleScript
set mySites to {"Minneapolis", "Cupertino", "New York", "Hong Kong", "Amsterdam", "Eau Claire"}
set selectedSite to {choose from list mySites}
AppleScript
echo "${theSite}"
)
}
getSite
echo "${theSite}"
# now select invitation codes
# put site names with spaces in single quotes
case ${theSite} in
Minneapolis)
invCode='1234567890';;
Cupertino)
invCode='0987654321';;
'New York')
invCode='6789012345';;
'Hong Kong')
invCode='8901234567';;
Amsterdam)
invCode='3456789012';;
'Eau Claire')
invCode='4567890123';;
esac
echo "put your enrollment command here with code ${invCode}"
exit 0
Is there away to change make a selection to something else?