-
Notifications
You must be signed in to change notification settings - Fork 45
/
MacOS.sh
42 lines (38 loc) · 1.5 KB
/
MacOS.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
#!/bin/bash
# Set variables
DOMAIN="test.com" # Active Directory domain name
ADMIN="admin" # AD admin username
PASS="password" # AD admin password (not encrypted, use with caution)
ADGROUP="whatevergroup" # AD group to add computer to (e.g. MacAdmins)
ADCOMPUTER="MACagent01" # Name of the computer object in Active Directory
OU="OU=Computers Mac,DC=domain,DC=com" # OU where the computer object will be created
# Prompt user for input
read -p "Enter Active Directory domain name: " DOMAIN
read -p "Enter AD admin username: " ADMIN
read -s -p "Enter AD admin password: " PASS
echo
read -p "Enter AD group to add computer to: " ADGROUP
read -p "Enter name of the computer object in Active Directory: " ADCOMPUTER
read -p "Enter OU where the computer object will be created: " OU
# Join computer to Active Directory
sudo dsconfigad -add "$DOMAIN" \
-mobile enable \
-mobileconfirm disable \
-localhome enable \
-protocol smb \
-shell '/bin/bash' \
-username "$ADMIN" \
-password "$PASS" \
-groups "$ADGROUP" \
-computer "$ADCOMPUTER" \
-ou "$OU"
if [ $? -ne 0 ]; then
echo "Error joining computer to Active Directory"
exit 1
fi
# Show Active Directory configuration
sudo dsconfig -show
if [ $? -ne 0 ]; then
echo "Error displaying Active Directory configuration"
exit 1
fi