Hi -- We're new to the JSS and are looking to create a script that will prompt the user on enrollment to choose if the device is Personal or Enterprise Owned, and then have it populate an Extension Attribute. Then we could create a smart group to exclude those personal devices from certain policies. Has anyone ever done something like this before or is there a better way?? Any help is GREATLY appreciated!
Enrollment Script

Best answer by mm2270
Well, someone may have already done this. In fact, I'm almost certain someone has. Whether they'll post what they've done I don't know.
For now, here's a very simple example to get you started on a path. Below is a bash script that calls an Applescript dialog. Here I'm just using buttons instead of choose from list. This actually helps prevent someone from just clicking the Cancel button and exiting without choosing 'something'. A button must be clicked to dismiss it in other words. As you'll see, it should create a file called "systemtype" in /private/var/ with a string of text in it. That text can later be picked up in a simple Extension Attribute script, which can populate your Smart Groups. The script runs a full inventory collection after, so it would hopefully pick up the user selection.
#!/bin/sh
selection=$(/usr/bin/osascript -e 'set userChoice to button returned of (display dialog "Choose the type of Mac you are enrolling from the list below" buttons {"Enterprise owned", "Personally owned"})')
if [ "$selection" == "Personally owned" ]; then
echo "Mac is personally owned"
echo "personal" > "/private/var/systemtype"
elif [ "$selection" == "Enterprise owned" ]; then
echo "Mac is enterprise owned"
echo "enterprise" > "/private/var/systemtype"
fi
jamf recon
The only thing about Applescript for this kind of stuff is that, starting around 10.8 and increasingly with each new OS X release, Apple has made it pretty hard to display dialogs to the end user unless they are run as the user. Since Casper Suite runs scripts as root by default, not the user, you may need to work around that to get the dialog to even display. Its very inconsistent in my experience when you'll get stopped in your tracks by sandboxing and when it just works. So try it as is, and see what happens.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.