Add text fields to DEPNotify script?

howie_isaacks
Valued Contributor

I have been wanting to add fields in the DEPNotify registration process for the user's full name and email address. I have successfully made the necessary modification to have a field for the user's full name. The documentation inside the script states, "Registration window can have up to two text fields". Is there a way to allow more? I also want a field to fill in the user's email address, and I don't want to take away the asset tag field. The fields I want to have are: computer name, user's full name, user's email address, and asset tag. I have a drop-down menu setup for building, which I renamed to Location since that would make more sence to the users who are following the registration process. The location drop-down menu sets the building value in the computer's inventory. In my tests, the script properly sets the computer name defined in the registration, the user's full name and the location (building). Can we add more text fields?

17 REPLIES 17

Hugonaut
Valued Contributor

You can always add a prompt after or before that step, pipe into a variable & pass that variable wherever, however you want. Below is an example of what I'm talking about, you could paste that directly into the depnotify script in your JSS & have it recon out the email address. I know its not as pretty as direct integration into depNotify but it works.  @howie_isaacks 

 

 

#!/bin/bash

############################### Howies Prompt for Email Address ################################
EmailAddress=$(osascript -e 'display dialog "Enter Email Address:" default answer "Placeholder@Placeholder.com" buttons {"Continue"} default button {"Continue"}
	set the EmailAddress to text returned of the result
	return EmailAddress')

jamf recon -email $EmailAddress

 

 

 

 

 

 

 

 

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman

I like this idea. @ljcacioppo mentioned something similar to this.

ljcacioppo
Contributor III

I think the only way to do this is currently by using a configuration profile to set up how that registration window works and only works on macOS 11. Here is the sample config profile that was posted in slack in the #depnotify channel

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
    <dict>
        <key>PayloadOrganization</key>
        <string>Joel</string>
        <key>PayloadDisplayName</key>
        <string>DEPNotify Custom menus</string>
        <key>PayloadScope</key>
        <string>System</string>
        <key>PayloadType</key>
        <string>Configuration</string>
        <key>PayloadDescription</key>
        <string>DEP Notify Testing</string>
        <key>PayloadContent</key>
        <array>
            <dict>
                <key>PayloadDescription</key>
                <string>Configures Custom Menus</string>
                <key>PayloadDisplayName</key>
                <string>DEPNotify Custom Menus</string>
                <key>PayloadOrganization</key>
                <string>Joel</string>
                <key>PayloadType</key>
                <string>menu.nomad.DEPNotify</string>
                <key>registrationMainTitle</key>
                <string>Welcome to the new registration!</string>
                <key>CustomMenus</key>
                <array>
                    <dict>
                        <key>Title</key>
                        <string>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eget augue lacinia, luctus massa vel, rhoncus erat. Donec convallis vel mi porta mollis. Morbi pulvinar sit amet odio non blandit. Donec gravida nibh efficitur nibh fermentum gravida. Fusce eget nisl elit. Nullam efficitur eget massa eu aliquet. Donec non nisl a augue consequat auctor. Maecenas et est placerat, molestie quam eget, vulputate ex. Nullam varius pharetra gravida. Praesent eget blandit tortor. Sed dignissim tellus erat, non mollis purus vestibulum quis. Morbi ac facilisis tellus.

Aenean id ornare dolor. Pellentesque vitae volutpat quam. Nam quam enim, semper vitae semper in, vulputate at dui. Quisque libero turpis, lacinia et ultricies et, placerat quis velit. Etiam imperdiet congue aliquet. Pellentesque mollis ornare dolor. Sed eget scelerisque libero, ac mollis turpis. In hac habitasse platea dictumst. Quisque scelerisque, odio a elementum euismod, velit quam euismod sem, et commodo mauris diam non odio. Etiam ligula dui, pretium at feugiat ut, commodo in erat.

Vivamus non quam suscipit sem pulvinar dapibus. Etiam sodales nibh quis velit elementum molestie. Donec condimentum sapien sit amet justo imperdiet tempus. Integer sit amet imperdiet dui. Nam pulvinar, turpis eget malesuada luctus, mi nibh iaculis tortor, vel gravida odio tellus quis massa. Cras quis enim odio. Maecenas quis justo non nisi ultricies consequat. Suspendisse imperdiet placerat urna, id ullamcorper tortor accumsan ut. Sed venenatis eget velit a egestas. Cras magna purus, pretium sit amet felis vel, viverra hendrerit risus. Nullam vel molestie magna. Donec quam sapien, tristique a viverra ac, imperdiet et urna. Morbi tincidunt enim nunc. Integer facilisis ullamcorper interdum.

Nulla eget leo ac elit dictum elementum. Donec augue nulla, ultricies sit amet scelerisque non, convallis a nunc. Nulla facilisi. Praesent lacus massa, pharetra quis elit sed, maximus faucibus quam. Integer commodo enim metus, ac pellentesque lorem facilisis ac. Quisque dignissim tincidunt justo, sit amet laoreet est laoreet ac. Pellentesque magna ante, egestas suscipit sodales ut, imperdiet id nisi. Aliquam erat volutpat. Nulla feugiat urna vel justo vehicula mattis. Proin vitae magna at urna mollis commodo et ac ligula.

Aliquam erat volutpat. Nunc ultricies metus vel mi consequat finibus. Aenean euismod, sem id iaculis tincidunt, mauris tortor vestibulum felis, in laoreet augue arcu et justo. Morbi gravida, est ac facilisis sollicitudin, elit nunc fermentum mauris, ut volutpat enim dolor eu metus. Nulla consequat quam eget sem feugiat varius. Aenean id velit vulputate, lobortis magna quis, sollicitudin ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Donec condimentum nulla eget ipsum aliquam lacinia. Duis tincidunt rhoncus mauris, tincidunt pellentesque mauris tincidunt ac. Aliquam eget leo rhoncus erat bibendum facilisis nec non metus. In non leo metus. Maecenas in nisi sit amet est egestas dapibus ac eget ante. Mauris faucibus vestibulum erat, eu tristique arcu viverra vitae. Mauris consequat, tellus a tempus aliquet, ipsum felis volutpat erat, id fermentum nibh justo a augue.</string>
                        <key>Type</key>
                        <string>Text</string>
                        <key>Tag</key>
                        <string>openingText</string>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Username</string>
                        <key>Type</key>
                        <string>TextField</string>
                        <key>Tag</key>
                        <string>user</string>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Password</string>
                        <key>Type</key>
                        <string>SecureTextField</string>
                        <key>Tag</key>
                        <string>pass</string>
                    </dict>
                    <dict>
                        <key>Tag</key>
                        <string>stars</string>
                        <key>Type</key>
                        <string>PullDown</string>
                        <key>Title</key>
                        <string>How many stars?</string>
                        <key>Items</key>
                        <array>
                            <string>****</string>
                            <string>*****</string>
                        </array>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Having Fun?</string>
                        <key>Type</key>
                        <string>Toggle</string>
                        <key>Tag</key>
                        <string>fun</string>
                    </dict>
                </array>
                <key>PayloadIdentifier</key>
                <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256.com.apple.TextEdit.DB9E6C61-63E1-4868-A878-8B88B57AAA66</string>
                <key>PayloadVersion</key>
                <integer>1</integer>
                <key>PayloadUUID</key>
                <string>DB9E6C61-63E1-4868-A878-8B88B57AAA66</string>
            </dict>
        </array>
        <key>PayloadIdentifier</key>
        <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256</string>
        <key>PayloadVersion</key>
        <integer>1</integer>
        <key>PayloadUUID</key>
        <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256</string>
    </dict>
</plist><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
    <dict>
        <key>PayloadOrganization</key>
        <string>Joel</string>
        <key>PayloadDisplayName</key>
        <string>DEPNotify Custom menus</string>
        <key>PayloadScope</key>
        <string>System</string>
        <key>PayloadType</key>
        <string>Configuration</string>
        <key>PayloadDescription</key>
        <string>DEP Notify Testing</string>
        <key>PayloadContent</key>
        <array>
            <dict>
                <key>PayloadDescription</key>
                <string>Configures Custom Menus</string>
                <key>PayloadDisplayName</key>
                <string>DEPNotify Custom Menus</string>
                <key>PayloadOrganization</key>
                <string>Joel</string>
                <key>PayloadType</key>
                <string>menu.nomad.DEPNotify</string>
                <key>registrationMainTitle</key>
                <string>Welcome to the new registration!</string>
                <key>CustomMenus</key>
                <array>
                    <dict>
                        <key>Title</key>
                        <string>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eget augue lacinia, luctus massa vel, rhoncus erat. Donec convallis vel mi porta mollis. Morbi pulvinar sit amet odio non blandit. Donec gravida nibh efficitur nibh fermentum gravida. Fusce eget nisl elit. Nullam efficitur eget massa eu aliquet. Donec non nisl a augue consequat auctor. Maecenas et est placerat, molestie quam eget, vulputate ex. Nullam varius pharetra gravida. Praesent eget blandit tortor. Sed dignissim tellus erat, non mollis purus vestibulum quis. Morbi ac facilisis tellus.

Aenean id ornare dolor. Pellentesque vitae volutpat quam. Nam quam enim, semper vitae semper in, vulputate at dui. Quisque libero turpis, lacinia et ultricies et, placerat quis velit. Etiam imperdiet congue aliquet. Pellentesque mollis ornare dolor. Sed eget scelerisque libero, ac mollis turpis. In hac habitasse platea dictumst. Quisque scelerisque, odio a elementum euismod, velit quam euismod sem, et commodo mauris diam non odio. Etiam ligula dui, pretium at feugiat ut, commodo in erat.

Vivamus non quam suscipit sem pulvinar dapibus. Etiam sodales nibh quis velit elementum molestie. Donec condimentum sapien sit amet justo imperdiet tempus. Integer sit amet imperdiet dui. Nam pulvinar, turpis eget malesuada luctus, mi nibh iaculis tortor, vel gravida odio tellus quis massa. Cras quis enim odio. Maecenas quis justo non nisi ultricies consequat. Suspendisse imperdiet placerat urna, id ullamcorper tortor accumsan ut. Sed venenatis eget velit a egestas. Cras magna purus, pretium sit amet felis vel, viverra hendrerit risus. Nullam vel molestie magna. Donec quam sapien, tristique a viverra ac, imperdiet et urna. Morbi tincidunt enim nunc. Integer facilisis ullamcorper interdum.

Nulla eget leo ac elit dictum elementum. Donec augue nulla, ultricies sit amet scelerisque non, convallis a nunc. Nulla facilisi. Praesent lacus massa, pharetra quis elit sed, maximus faucibus quam. Integer commodo enim metus, ac pellentesque lorem facilisis ac. Quisque dignissim tincidunt justo, sit amet laoreet est laoreet ac. Pellentesque magna ante, egestas suscipit sodales ut, imperdiet id nisi. Aliquam erat volutpat. Nulla feugiat urna vel justo vehicula mattis. Proin vitae magna at urna mollis commodo et ac ligula.

Aliquam erat volutpat. Nunc ultricies metus vel mi consequat finibus. Aenean euismod, sem id iaculis tincidunt, mauris tortor vestibulum felis, in laoreet augue arcu et justo. Morbi gravida, est ac facilisis sollicitudin, elit nunc fermentum mauris, ut volutpat enim dolor eu metus. Nulla consequat quam eget sem feugiat varius. Aenean id velit vulputate, lobortis magna quis, sollicitudin ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Donec condimentum nulla eget ipsum aliquam lacinia. Duis tincidunt rhoncus mauris, tincidunt pellentesque mauris tincidunt ac. Aliquam eget leo rhoncus erat bibendum facilisis nec non metus. In non leo metus. Maecenas in nisi sit amet est egestas dapibus ac eget ante. Mauris faucibus vestibulum erat, eu tristique arcu viverra vitae. Mauris consequat, tellus a tempus aliquet, ipsum felis volutpat erat, id fermentum nibh justo a augue.</string>
                        <key>Type</key>
                        <string>Text</string>
                        <key>Tag</key>
                        <string>openingText</string>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Username</string>
                        <key>Type</key>
                        <string>TextField</string>
                        <key>Tag</key>
                        <string>user</string>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Password</string>
                        <key>Type</key>
                        <string>SecureTextField</string>
                        <key>Tag</key>
                        <string>pass</string>
                    </dict>
                    <dict>
                        <key>Tag</key>
                        <string>stars</string>
                        <key>Type</key>
                        <string>PullDown</string>
                        <key>Title</key>
                        <string>How many stars?</string>
                        <key>Items</key>
                        <array>
                            <string>****</string>
                            <string>*****</string>
                        </array>
                    </dict>
                    <dict>
                        <key>Title</key>
                        <string>Having Fun?</string>
                        <key>Type</key>
                        <string>Toggle</string>
                        <key>Tag</key>
                        <string>fun</string>
                    </dict>
                </array>
                <key>PayloadIdentifier</key>
                <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256.com.apple.TextEdit.DB9E6C61-63E1-4868-A878-8B88B57AAA66</string>
                <key>PayloadVersion</key>
                <integer>1</integer>
                <key>PayloadUUID</key>
                <string>DB9E6C61-63E1-4868-A878-8B88B57AAA66</string>
            </dict>
        </array>
        <key>PayloadIdentifier</key>
        <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256</string>
        <key>PayloadVersion</key>
        <integer>1</integer>
        <key>PayloadUUID</key>
        <string>8A66ADFA-18F7-4E4D-ACE1-4A0A7A56E256</string>
    </dict>
</plist>

 

Here's some of the notes regarding it:

Here's a run at Dynamic Menus for the Registration window
You can have Text, TextField, SecureTextField, PullDown and Toggle as types
feel free to create as many of any of those as you like and in any order
each item has a Title and a Tag
the Title will be displayed in the UI
the Tag will be used when the resulting information is written out
Currently this replaces the existing registration screen for macOS 11 or later, but I'm open to opinions on that

Interesting. So I guess the script itself can't be modified to do this then. I will try this out. I wish the creator of DEPNotify had anticipated the need for more text fields. I may also look into other solutions instead of using DEPNotify.

Correct, the script you cannot have more than 2 text fields. The creator of DEPNotify is the one who provided the config profile to allow for more customization, but I personally have always been able to get by without that many text fields.

Personally, I use an identity provider (LDAP/SSO) to get the users full name and email address, and then those fields are no longer needed. Or depending on what youre naming the computers, is there a way to have the script generate that where it doesn't need to be a text field?


I have several Jamf Pro servers, each customized for a different client. I was hoping for a way to make sure that a user's full name and email address get added to the machine record. I may instead write a script that would pull the full name of the user, and then write that information into the full name field in User and Location. I can try to use an SSO to obtain this information. I will explore that too. Currently, all user logins on Macs is local.

I use local accounts as well. I use an Enrollment Customization to prompt for authentication when the computer enrolls in remote management, which then links the device to the user and performs the user lookup with the IdP and fills out the email, location, name, etc.

And then DEPNotify prompts for the asset tag, etc.

howie_isaacks
Valued Contributor

I appreciate all of the suggestions. I have been devoting a lot of time lately to improving my Jamf Pro deployments, and Jamf Nation has been a huge help doing that.

howie_isaacks
Valued Contributor

I created a script that uses osascript to prompt the user for their name and email address. The prompts appear one right after the other, but what happens is that the script sends the word "button" to both the full name and email address fields in the machine record. I'm sure there's a fix for this. The script I made is below. A few weeks ago I was working on creating an extension attribute to return a specific value, but the output of the commands had additional text in addition the result I wanted to track with the EA. So, I used this command to extract only what I wanted: folderSize=$(echo $size | awk '{print $1}'). This resulted with only the number value instead of the extra text. The output from the command asking for the user's name returns something like this: button returned:Continue, text returned:Steve Jobs. So if I then enter fullname=$(echo $name | awk '{print $4}'), and then echo $fullname I get: returned:Steve 🤬 So.... There has to be another way to prompt a user for their name and email address that does not produce unusable results. As it stands now, when a Mac enrolls, we have to watch for the new enrollment, and then manually enter the user's full name and email address.

 

#!/bin/bash

#Prompts the user for their name and email address during enrollment, then submits this information to Jamf Pro.

name=$(osascript -e 'display dialog "To start your Mac setup process, please enter your first and last name. Next you will be asked for your email address." default answer "Someone Awesome" buttons {"Continue"} default button {"Continue"}')

email=$(osascript -e 'display dialog "Please enter your email address." default answer "SomeoneAwesome@domain.com" buttons {"Continue"} default button {"Continue"}')

jamf recon -realname $name
jamf recon -email $email

 

 

howie_isaacks
Valued Contributor

Since the osascript prompts to fill in the user's full name and email address don't work as intended, I created this script to get the user's full name automatically. It can be run at check-in, or I may run it upon enrollment. I will do some testing to figure out what works best. But how do I collect the email address? There has to be a way to prompt for this information and actually get a usable result.

 

 

#!/bin/sh

#Gets the full name of the logged in user.

#Who is the current logged in user?
currentUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
echo $currentUser

#What is the full name of the current logged in user?
fullName=$(dscl . read /Users/$currentUser RealName | grep -v RealName | cut -c 2-)
echo $fullName

#Write the full name of the current logged in user to the Mac's inventory.
jamf recon -realname "$fullName"

# Howie Isaacks with help from Jamf Nation | F1 Information Technologies | 08/27/21

 

 

If you have LDAP/SSO configured, and you have the email address, full name, etc pointed to the appropriate locations in the IdP, then all you would need is the username

and then run

jamf recon -endUsername $username

would populate all of the fields for you

We're not using LDAP right now. All of our clients use Azure AD since it's part of Microsoft 365, but I have not tied it into Jamf Pro yet since we have not had any specific needs to do so. But... I think I have this figured out with the osascript prompts. As I've said, the issue with using osascript prompts was that the submitted information would look like this: button returned:Continue, text returned:name@domain.com That result has a lot of useless text. So, I had to find a way to remove everything but what the user actually entered. I used sed (stream editor) to remove the extra text. Here's the final script that works perfectly. Now I can keep using DEPNotify with its two text field limitation and still get the information I need in each Mac's inventory record. I may also start prompting for phone numbers too.

#!/bin/sh

#Prompts for the user's full name and email address then sends the submitted information to the Mac's inventory in User and Location.

#Prompt user for their name.
nameSubmitted=$(osascript -e 'display dialog "Please enter your name. When prompted, please enter your email address. These will be included in the inventory record for your Mac." default answer "" buttons {"Continue"} default button "Continue"')
echo $nameSubmitted

#Prompt user for their email address.
emailSubmitted=$(osascript -e 'display dialog "Please enter email address." default answer "" buttons {"Continue"} default button "Continue"')
echo $emailSubmitted

#Convert the results from user inputs to a form usable by Jamf Pro.
realName=$(echo $nameSubmitted | sed 's/button returned:Continue, text returned://')
echo $realName

emailAddress=$(echo $emailSubmitted | sed 's/button returned:Continue, text returned://')
echo $emailAddress

#Send the user's name and email address to the Mac's inventory record. Use double quotes for realName to capture first and last name entered by the user.
jamf recon -realname "$realName"
jamf recon -email $emailAddress

 

You could use text returned from the osascript instead of using sed FYI

emailSubmitted=$(osascript -e 'text returned of (display dialog "Please enter email address." default answer "" buttons {"Continue"} default button "Continue")')

Please forgive me. I'm learning. I have only used osascript a few times so I don't know all of the bells and whistles. I remember using sed while working with Linux so I tried it and it worked for this particular issue. I wish I had remembered to use it while building an extension attribute a while back. I appreciate all the input. Jamf Nation is awesome.

No need to apologize. Just figured I’d give you that info in case you need to use it for this or future scripts to save you some time and additional lines of code. 

I have already saved that info in my notes. Thank you!