Posted on 06-24-2022 04:16 PM
Greetings,
Below is a script I have been using with success on older versions of macOS however, it stopped working on monetary.
The script pulls the current username from "ls -l /dev/console | cut -d " " -f 4" and automatically sets the ComputerName, HostName, and LocalHostName as the current username.
Any thoughts on how to get this working again on this version of MacOS? Thanks, ~ B
##### Script
#!/bin/sh
username=`ls -l /dev/console | cut -d " " -f 4`
scutil --set ComputerName "$4""$username"
scutil --set HostName "$4""$username".<domain>
scutil --set LocalHostName "$4""$username"
jamf recon
###########
Script exit code: 2 |
Script result: /Library/Application Support/JAMF/tmp/network name auto: line 8: syntax error near unexpected token `newline' /Library/Application Support/JAMF/tmp/network name auto: line 8: `scutil --set HostName "$4""$username".<domain>' |
Error running script: return code was 2. |
Posted on 06-24-2022 05:12 PM
Maybe something like this would work?
#!/bin/zsh
user_name=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
/usr/sbin/scutil --set HostName "$user_name".domain
/usr/sbin/scutil --set LocalHostName "$user_name"
/usr/sbin/scutil --set ComputerName "$user_name"
Posted on 06-27-2022 03:02 AM
Hi @bcrockett , I am using this script to rename the client name and it works well:
Posted on 06-27-2022 08:03 AM
Thanks, @Anonymous I will try that out. ~B
Posted on 06-27-2022 02:18 PM
Oh @bcrockett, you didn't like my script? I wrote it especially for you 😿
Posted on 06-27-2022 02:31 PM
@user-YshbQMtOGr I tried it and did not see great results. It may be due to the JAMF Pro data tables not being updated after the policy with the script runs and waiting for JAMF recon. However, even with Jamf Recon added to it, there seems to be a noticeable lag.
Posted on 06-27-2022 02:37 PM
Well thanks for giving it a shot. I thought it would work for sure! Hopefully @Anonymous's script works better.