Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Only root should run this
- #
- if [ $USER != 'root' ]
- then
- echo Only root may use this command\!
- echo Prefix your command line with '"'sudo '"'
- echo Exiting...
- echo ' '
- exit
- fi
- # Explain what is going to happen
- #
- echo ' '
- echo This script will join the system to UMN.DS. The computer
- echo account must exist in Active Directory before this script is run.
- NUMBER=`system_profiler | grep "Serial Number (system):" | awk '{print $4}' | sed 's/[:]//g' | awk '{ print substr( $0, length($0) - 7, length($0) ) }'`
- AD_COMPUTERNAME='L-X8-'$NUMBER
- echo $AD_COMPUTERNAME
- AD_ADMINUSER="administrator"
- AD_PASSWORD="hello4world"
- AD_OU="OU=MA,OU=Ugs,OU=Skola,OU=Computers,OU=UK,DC=udn,DC=ds"
- scutil --set ComputerName $AD_COMPUTERNAME
- scutil --set LocalHostName $AD_COMPUTERNAME
- scutil --set HostName $AD_COMPUTERNAME
- # Join computer to Active Directory
- #
- # We skip the flags "-alldomains enable -localhome enable" since they are
- # enabled by default.
- #
- dsconfigad -add udn.ds -username $AD_ADMINUSER -password $AD_PASSWORD -computer $AD_COMPUTERNAME -ou $AD_OU -localuser lokaladmin -force
- dsconfigad -mobile enable -mobileconfirm disable -useuncpath enable
- sleep 5
- exit 0
- #
- ##[The End]##
Add Comment
Please, Sign In to add comment