Hey all, I am looking to create a script that when ran it will grab the Serial Number and set it as the HostName, LocalHostName, & ComputerName. I needed some help with getting it to run without the prompt for an Administrator username and password. So far this is what I have below and I apologize ahead of time I am VERY new to this and trying to learn.
set sys to do shell script "/usr/sbin/system_profiler SPHardwareDataType " without altering line endings
set StringVariable1 to "Serial"
set Serial_Number to do shell script "/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial/ { print $NF }' "
do shell script "scutil --set HostName " & Serial_Number with administrator privileges
do shell script "scutil --set LocalHostName " & Serial_Number with administrator privileges
do shell script "scutil --set ComputerName " & Serial_Number with administrator privileges
display dialog "The Mac has been renamed to " & Serial_Number