aarondavidpolley/ScriptRepo

you have lots of extra

Closed this issue · 1 comments

#!/bin/bash

prefix="${4:-ACME-}"
serial=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Serial Number/{print $NF}')
compnm="${5:-$prefix$serial}"
/usr/sbin/scutil --set ComputerName "$compnm"
echo "$(/usr/sbin/scutil --get ComputerName)"
echo "$(/usr/sbin/scutil --get HostName)"
echo "$(/usr/sbin/scutil --get LocalHostName)"

that's it.

Thanks for the feedback @fredjohnsen - apologies it took me 2 years to realise it was here. 😂

Are you referring to https://github.com/aarondavidpolley/ScriptRepo/blob/master/JamfPro-Casper-SetComputerName_Serial.sh ?

I was not aware of Parameter Expansion (https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion). I'll keep it in mind for future, its pretty cool!

Thanks again