Rename computer via self service with dialog box

josefrometa
New Contributor II

I want a simple script to add to self service which will give me a dialog box with some selection/drop-down and some text boxes which will all tie together at the end to create the name and then recon to push to jamf.

Drop-down will have 4 choices each and everything will be selected manually.

Final name will be

Example: NA.John.Doe.M1Pro14

82E4B015-A2A5-4C27-A2EE-93972213CE05.jpeg

1 REPLY 1

pete_c
Contributor III

Use cocoaDialog or osascript to capture names if you're not assigning them in the Jamf Pro server first - see here for a good start - but why give users the option to incorrectly enter hardware info?  Just grab it programmatically:

 

serial=$(ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}')
model=$(/usr/sbin/sysctl -n hw.model)
hwmodel=$(ioreg -l | awk '/product-name/ { split($0, line, "\""); printf("%s\n", line[4]); }')
platform=$(/usr/bin/arch)
processor=$(/usr/sbin/sysctl -n machdep.cpu.brand_string)