cyrax
asked on
Script to add computer to Windows domain
Hello,
Need a script that adds a Windows XP computer from one domain to another domain.
Can anyone help?
THank you!
Need a script that adds a Windows XP computer from one domain to another domain.
Can anyone help?
THank you!
ASKER
Is there a way of performing the task without using the Netdom command? Would prefer a script if possible.
Thanks.
Thanks.
You can place a call to that in a script shell object, but I have not seen anything to do it without using the netdom join command.
My apologies, try this: http://cwashington.netreach.net/depo/view.asp?Index=1144&ScriptType=vbscript
Scroll down the page, and look for the routine "Sub Join2Domain". It states it only works on WinXP, but that is what you were looking for.
Scroll down the page, and look for the routine "Sub Join2Domain". It states it only works on WinXP, but that is what you were looking for.
ASKER
Since the computer is already on a domain, and I need to join it to another domain, does it need to be disjoined from the existing domain and added to a workgroup first before joining it to the new domain?
The heart of the Join2Domain routine is the method "JoinDomainOrWorkgroup" (in detail on MSDN http://msdn2.microsoft.com/en-us/library/aa392154.aspx). It says you must remove from the domain if adding to a workgroup, but you can force it to move from one domain to another through the last parameter.
In the code sample on netreach.net (in previous post), you would modify:
-------------
ReturnValue = objComputer.JoinDomainOrWo rkGroup(st rDomain, _
strPassword, _
strDomain & "\" & strUser, _
strOU, _
JOIN_DOMAIN + ACCT_CREATE)
-------------
to read:
-------------
ReturnValue = objComputer.JoinDomainOrWo rkGroup(st rDomain, _
strPassword, _
strDomain & "\" & strUser, _
strOU, _
DOMAIN_JOIN_IF_JOINED)
-------------
The variable "DOMAIN_JOIN_IF_JOINED" is specified a few lines above (in the article) as having value 32. This can be combined with other options (that the author specified in those constants) by adding them, similar to the author's use of "JOIN_DOMAIN + ACCT_CREATE".
Alternately, there is a method called "UnjoinDomainOrWorkgroup" (in detail on MSDN http://msdn2.microsoft.com/en-us/library/aa393942.aspx), which you could perform prior to joining the new domain.
Hope this helps.
In the code sample on netreach.net (in previous post), you would modify:
-------------
ReturnValue = objComputer.JoinDomainOrWo
strPassword, _
strDomain & "\" & strUser, _
strOU, _
JOIN_DOMAIN + ACCT_CREATE)
-------------
to read:
-------------
ReturnValue = objComputer.JoinDomainOrWo
strPassword, _
strDomain & "\" & strUser, _
strOU, _
DOMAIN_JOIN_IF_JOINED)
-------------
The variable "DOMAIN_JOIN_IF_JOINED" is specified a few lines above (in the article) as having value 32. This can be combined with other options (that the author specified in those constants) by adding them, similar to the author's use of "JOIN_DOMAIN + ACCT_CREATE".
Alternately, there is a method called "UnjoinDomainOrWorkgroup" (in detail on MSDN http://msdn2.microsoft.com/en-us/library/aa393942.aspx), which you could perform prior to joining the new domain.
Hope this helps.
ASKER
Thanks. Still trying the NETDOM solution, but can't seem to get it to work...
Is it necessary to specify the OU in the command string?
Which NETDOM should be used - one from a Windows XP CD or a Windows Server 2003 CD? I noticed that they are different.
Is it necessary to specify the OU in the command string?
Which NETDOM should be used - one from a Windows XP CD or a Windows Server 2003 CD? I noticed that they are different.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
netdom join %computername% /Domain:<Domainname>/UserD