-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRename_Computer_Name_to_Serial_EA.sh
48 lines (32 loc) · 1.17 KB
/
Rename_Computer_Name_to_Serial_EA.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# Jason Filice
# Technology Support Services in IT
# California State University, Monterey Bay
# http://csumb.edu/it
# This script will rename the computer name to serial number or ComputerName value from Jamf Pro Extension Attributes.
SCRIPTNAME=`/usr/bin/basename "$0"`
SCRIPTPATH=`/usr/bin/dirname "$0"`
# Jamf JSS Parameters 1 through 3 are predefined as mount point, computer name, and username
pathToScript=$0
mountPoint=$1
computerName=$2
userName=$3
shift 3
# Shift off the $1 $2 $3 parameters passed by the JSS so that parameter 4 is now $1
## Variables ##
# Run jamf policy which should try to load any missing config profiles and managed prefs.
# /usr/local/bin/jamf policy -forceNoRecon -showPID
plistlocation="/Library/Managed Preferences/edu.csumb.custom.extensionattributes.plist"
if [[ -e "$plistlocation" ]]; then
ComputerName=$(/usr/bin/defaults read "${plistlocation}" "Computer_Name" 2>/dev/null)
else
ComputerName=""
fi
if [[ ! -z "${ComputerName}" ]]; then
/usr/local/bin/jamf setComputerName -name "${ComputerName}"
else
/usr/local/bin/jamf setComputerName -useSerialNumber
fi
/usr/local/bin/jamf recon -showPID
exit 0