Posted on 04-02-2013 12:53 PM
In the process of purchasing about ~120 new Macs that are assigned to employees by Serial Number. We use a naming convention that includes their Department, Room Number, and Username to name these machines. I wanted to use PreStage imaging to load in the Serial Numbers and then Computer Names that I want so I can include binding to the domain in the workflow. I don't think this is possible.
Has anyone figured out a script to map Serial Numbers to Computer Names so that I can rename at first boot (maybe) and then I can join to domain with policy?
Any ideas are appreciated - thanks!
Posted on 04-02-2013 01:07 PM
I remember trying to attempt this early on in our use of Casper. I gave up at the time, opting to manually rename them after (via the JSS). Obviously that's not optimal. I will be running another mass imaging in September and we will be naming via AD... however, I did think of one thing that might help you.
Technically, you could create separate pre-stage's. For example, you setup a prestage for your first group (naming conventions included), then copy it for as many departments as you have, changing only the serial numbers in the group and the department names. I don't know how many prestages you have, but hey.
Posted on 04-02-2013 01:10 PM
The problem is that we put unique information in the computer name that is not information that a script can pull from a machine. For example, the Room Number, and Username.
I was thinking of a script that basically looked at a CSV of Serial Numbers in Column A and Computer Name in Column B and said "If Serial number equals 123456X, then set computer name to Value of Column B" (for example).
Posted on 04-02-2013 01:36 PM
Do you have any type of authentication service? AD or anything LDAPy?
Posted on 04-02-2013 01:36 PM
AD, yes
Posted on 04-02-2013 01:37 PM
You might want to take a look at the Casper SDK download from JAMF's site. There is a utility, as an example, that can use a specially crafted csv file to pre-import and create computer accounts in your JSS. Its called the JSS Computer Importer, or something along those lines.
The csv can include a lot of information, including things like room number if I'm not mistaken. MAC address might be a requirement for them to be created, which could be problematic unless you have access to a list from the company you're ordering the Macs from ahead of time.
Provided that won't be a showstopper, I wonder if you could use that to pre-create the computer records, then actually image them afterwards in a Pre-Stage, and they would match up with the existing records. The only thing is, I'm unclear if supplying a name in the Pre-Stage would be an absolute requirement, which would end up renaming all the Macs when they get imaged. Kinda hard to tell how that would all work in tandem.
Still, I would take a look at that utility. It might be helpful in your case.
Posted on 04-04-2013 06:57 AM
That looks like a pretty good way, but you can also pull the info from the AD. See page 92 of the Casper Administrators guide for the mappings. We've not set it up here yet as we're preparing to shift from OLDAP to AD, but this is what we're prepping to use. So far as I can tell, you just need to have all the records setup properly in AD and then it will pull after imaging.
Posted on 05-27-2016 01:02 AM
Hi Chris,
Am wondering if you can point out where this is referenced in the current admin guide since the online version (http://docs.jamfsoftware.com/9.92/casper-suite/administrator-guide/index.html) does not appear to use page numbers?
Thanks!
Posted on 05-27-2016 06:02 AM
#!/bin/bash
####################################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
# renamebind.sh -- Renames computer based on Serial Number value in csv. Then binds to Cloud domain.
#
# SYNOPSIS
# sudo renamebind.sh
#
####################################################################################################
#
# HISTORY
#
# Version 0.3
# - Modified by Warren Santner
# - Added awk command to parse computer name from tab delimited text file
#
# Version: 0.2
# - Created by Randy Shore on April 23, 2013
# - Modified by Warren Santner
####################################################################################################
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
echo "-----V10-----"
tld="DOMAIN"
bound=$(dsconfigad -show | grep DOMAIN)
echo $bound
if [ -n "$bound" ]; then
echo "Unbinding from Domain..."
dsconfigad -remove -force -username "username" -password "password"
else
echo "Machine is not bound, no need to unbind"
fi
serial=`/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Serial Number (system)/ {print $NF}'`
echo "Serial Number:" $serial
curl --user JAMFUSER:JAMFPASSWORD http://path/to/list/of/serials.txt -O
computername=`awk -v serial=$serial '{if ($1 == serial) print $2;}' serials.txt`
echo "Computer Name:" $computername
if [ "$computername" != "" ]; then
sudo /usr/sbin/scutil --set ComputerName $computername
cnresult=`scutil --get ComputerName`
if [ "$cnresult" == "$computername" ]; then
echo $cnresult "is set as Computer Name"
else
echo "Error: name mismatch - ComputerName"
exit 1
fi
echo $computername
sudo /usr/sbin/scutil --set LocalHostName $computername
lhnresult=`/usr/sbin/scutil --get LocalHostName`
if [ "$lhnresult" == "$computername" ]; then
echo $lhnresult "is set as LocalHostName"
sudo /usr/sbin/scutil --set HostName "${computername}.${tld}"
sleep 1
hnresult=`/usr/sbin/scutil --get HostName`
echo $hnresult "is set as HostName"
else
echo "Error: name mismatch - HostName"
exit 1
fi
sleep 60
sudo jamf policy -trigger bind
echo "$computername has been bound to $tld"
else
echo "Error: $serial is not in serials.txt."
exit 1
fi
Posted on 05-27-2016 06:47 AM
Macs come in a few at a time rather than large batches where I work, so I approached this somewhat backwards compared to everyone else. I've created separate prestages for each machine by cloning, given each a different AD name, and then had a policy run a crude script to name the computer based on the AD name. This also helped with a problem of machine needing to be in specific OUs.
compname=$(/usr/sbin/dsconfigad -show | /usr/bin/sed -n 's/$//;s/Computer.Account {17}= //p;')
/usr/sbin/scutil --set ComputerName $compname
/usr/sbin/scutil --set HostName $compname
/usr/sbin/scutil --set LocalHostName $compname
/usr/local/bin/jamf recon