NONEXECUTABLE
Listing 1: Script to Update the Local Administrators Group
and Move Servers to a New Domain
@echo off
CLS
Rem This utility copies the existing Northamerica administrative
Rem grouping structure to each server/domain controller
Rem and relocates the server to the USA-PLEASANTON domain
Rem
Rem ==========================================================
Rem | Written by Robert Pierce |
Rem ==========================================================
Rem
Rem This utility relies on the following resource kit utilities:
Rem netdom.exe
Rem sleep.exe
Rem shutdown.exe
if .%1==. goto help
if "%1"=="/?" goto help
Rem p1 parameter is the site code for the resource domain
Rem p2 parameter is the name of the new resource domain
set common=\\psp-common-01\migration\common
set logfile=c:\temp\move_server.log
set siteadm=%1
set newdomain=%2
Rem initialize log file
@echo. > %logfile%
cls
@echo This may take a few minutes...
%common%\sleep 5
Rem Setting Administrative structure
@echo Setting Administrative structure including %siteadm%
admins. >> %logfile%
@echo setting administrative structure...
@echo Setting global administration structure...
net localgroup administrators
/add NORTHAMERICA\GLOBALADMINS >> %logfile%
net localgroup administrators
/add NORTHAMERICA\%1-NetSvcs > %logfile%
Rem Move the server to the new resource domain
@echo.
@echo Creating computer account in domain %newdomain%
@echo Creating computer account in domain %newdomain%
>> %logfile%
@echo %common%\netdom /user:NORTHAMERICA\migadm
/password:migadm /domain:%newdomain% MEMBER
%computername% /add >> %logfile%
%common%\netdom /user:NORTHAMERICA\migadm /password:migadm
/domain:%newdomain% MEMBER %computername%
/add >> %logfile%
@echo.
@echo Joining domain %newdomain%
@echo Joining domain %newdomain% >> %logfile%
@echo %common%\netdom /user:NORTHAMERICA\MIGACCOUNT
/password:<password> /domain:%newdomain%
MEMBER %computername% /JOINDOMAIN >
%temporary%\netdom.log >> %logfile%
%common%\netdom /user:NORTHAMERICA\MIGACCOUNT
/password:LETMEDOIT /domain:%newdomain%
MEMBER %computername% /JOINDOMAIN >
%temporary%\netdom.log >> %logfile%
Rem Sleep for 40 seconds and give the computer time to join the new domain
%common%\sleep 40
Rem ================================================================
Rem Reboot the server to implement the change to the domain
Rem Reboot is necessary so that ACLs across the
trusts will work properly
cls
@echo Press CTRL+C to abort the reboot; press
any other key to reboot this system. >> %logfile%
@echo Press CTRL+C to abort the reboot; press
any other key to reboot this system.
@echo Be aware that ACLs will not work properly
until you reboot system! >> %logfile%
@echo Be aware that ACLs will not work properly
until you reboot system!
pause
%common%\shutdown /L /R /T:00 /C /Y
|