Greetings all,
I have a script (I did not create this) to allow techs to manually set the Mac computer, localhost, and host names that runs as part of a policy. Until OS 12.3 came out, it worked just fine. This is the script:
#!/bin/zsh
defaults=/usr/bin/defaults
CurrentUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\\n");')
MacName=$(sudo -u "$CurrentUser" /usr/bin/osascript -e 'tell application "System Events" to set MacName to text returned of (display dialog "Enter the new Computer Name:" buttons "Continue" default button "Continue" default answer "" with icon 1)')
scutil --set ComputerName "$MacName"
scutil --set HostName "$MacName"
scutil --set LocalHostName "$MacName"
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$MacName"
On 12.3 the script fails due to python command not being found. So I found that with OS 12.3 Apple finally disabled Python 2.7 entirely so I thought installing Python3 as well as modifying the script to call python3 instead of python would do it.
Nope!
Now, Jamf Pro shows this as the error in the log:
Script result: Traceback (most recent call last):
File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'SystemConfiguration' usage: sudo -h | -K | -k | -V usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user] usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command] usage: sudo [-AbEHknPS] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>] usage: sudo -e [-AknS] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T timeout] [-u user] file ...
Scripting is still a weak area for me so I humbly ask the more script-savvy among you to help. If there's a better way to display a prompt for my techs to manually enter a computer name than this, I'm open to suggestions! If it's a script of some kind that can run as part of a policy that would be ideal.
Thank you!