Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining clients to new domain 1

Status
Not open for further replies.

theharmonyguy

Programmer
Jul 13, 2004
7
US
Another question . . . :) I appreciate the help.

I'm working on migrating an NT4 network to a Win2k server. The new server is setup on a domain with a different name.

All the clients (including XP, NT4, and 9x) are members of the old domain currently. I've gotten the user profiles setup on the new domain, so I can login from a client to the new domain. But the computer itself is still a member of the old one unless I go in manually (e.g. right-click My Computer, Properties, Computer Name, Change) and change the domain.

Is there a way to automatically make the client join the new domain, like with a logon script?

I've seen people talk about netdom, but I need to know exactly how to do this - I've tried creating a .bat with netdom and it hasn't worked so far.

Any ideas? Thanks!
 
Here you go, this script will disjoin from one domain and rejoin another. You will need to know the local admin password for the workstations, so make sure that is synchronized. (I have a script for it too if you need it).

Edit this script for the appropriate Admin ID & Password information.

Please not that this will not work on 9x clients.

Code:
'==========================================================================
'
' NAME: NetDomJoinWorkstations
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 6/24/2003
'
' COMMENT: Joins computers to a new domain.  Edit domain name, 
' user ID and passwords below.  Uses a workstation list wslist.txt. 
' Modification 7/28/2003 to include Remove command.  Suggest synchronizing old and new server passwords 
'
'==========================================================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close

For Each strWorkstation In RemotePC
'Do something useful with strWorkstation
Call WSHShell.Run("cmd.exe /c NETDOM REMOVE " & strWorkstation &"/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:30000")
Wscript.sleep 15000
Call WSHShell.Run("cmd.exe /c NETDOM JOIN " & strWorkstation &"/Domain:<domain> /UserD:<user> /PasswordD:<password> UserO:<user> /PasswordO:<password> /REBoot:0")

Next

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hey Mark:

Thats nice !

is that WMI ?

What would you suggest a good book or resource if I want to begin writing scripts to do my dirty jobs

Thanks

XM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top