Setting your arbitrary computer naming convention during DEP enrollment

A simple script that creates computer names using the logged in user.



Or rather, how I set our arbitrary computer naming convention on a machine during DEP enrollment. At my shop, we use the format $username-mac to name our Macs. I'm not sure why, or why it really matters, but for some reason some organizations get really weird and particular about computer names. Most of it comes down to not utilizing reporting tools well to do computer record/detail lookups imho. Anyway.



Here's what it does:

  • Detects location of jamf binary on the machine
  • Detects the username of the logged-in user (so this works best if you have the user create their account during DEP enrollment/setup assistant
  • Formats the computer name in the way we want it
  • Uses scutil to set computer name/hostname/local hostname
  • Sets the NetBIOS name to match
  • Is probably too thorough and then uses jamf's setComputerName to set the name as well
  • Throws in some echos for good measure

I use it in one of the enrollmentComplete policies, scoped to our DEP PreStage Enrollment machines, before a recon.

I'd be happy using, like, any computer name but, well, I do what I'm told. Hopefully the above helps some of you out too.

Pleeeeeeease test before deploying!

Write a comment