Join Computer to a Domain 
Author Message
 Join Computer to a Domain

I'm trying to write a script to join a computer to our Windows 2000 domain.
I found the following code on MS's TechNet Script Center:

===== Begin code =====
Const JOIN_DOMAIN             = 1
Const ACCT_CREATE             = 2
Const ACCT_DELETE             = 4
Const WIN9X_UPGRADE           = 16
Const DOMAIN_JOIN_IF_JOINED   = 32
Const JOIN_UNSECURE           = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET        = 256
Const INSTALL_INVOCATION      = 262144

strDomain   = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser     = "shenalan"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" &
_
                   strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" &
_
                   strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
                                                strPassword, _
                                                strDomain & "\" & strUser, _
                                                NULL, _
                                                JOIN_DOMAIN + ACCT_CREATE)
===== End Code =====

Looks great, but when I run it I get the message that the objComputer
"doesn't support this property or method: 'JoinDomainOrWorkGroup'".

Any ideas?

Thanks,

Tom



Tue, 14 Jun 2005 21:56:37 GMT  
 Join Computer to a Domain
It could just be the word wrap but why is the underscore on it's own line in
the objComputer section?


Quote:
> I'm trying to write a script to join a computer to our Windows 2000
domain.
> I found the following code on MS's TechNet Script Center:

> ===== Begin code =====
> Const JOIN_DOMAIN             = 1
> Const ACCT_CREATE             = 2
> Const ACCT_DELETE             = 4
> Const WIN9X_UPGRADE           = 16
> Const DOMAIN_JOIN_IF_JOINED   = 32
> Const JOIN_UNSECURE           = 64
> Const MACHINE_PASSWORD_PASSED = 128
> Const DEFERRED_SPN_SET        = 256
> Const INSTALL_INVOCATION      = 262144

> strDomain   = "FABRIKAM"
> strPassword = "ls4k5ywA"
> strUser     = "shenalan"

> Set objNetwork = CreateObject("WScript.Network")
> strComputer = objNetwork.ComputerName

> Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
&
> _
>                    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='"
&
> _
>                    strComputer & "'")

> ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
>                                                 strPassword, _
>                                                 strDomain & "\" & strUser,
_
>                                                 NULL, _
>                                                 JOIN_DOMAIN + ACCT_CREATE)
> ===== End Code =====

> Looks great, but when I run it I get the message that the objComputer
> "doesn't support this property or method: 'JoinDomainOrWorkGroup'".

> Any ideas?

> Thanks,

> Tom



Tue, 14 Jun 2005 22:07:56 GMT  
 Join Computer to a Domain
It is just the word wrap.  I just copy and pasted that code from this web
page:

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/sc...
ter/compmgmt/default.asp

(watch the wrap)

Tom


Quote:
> It could just be the word wrap but why is the underscore on it's own line
in
> the objComputer section?



Tue, 14 Jun 2005 22:37:19 GMT  
 Join Computer to a Domain
That method is imlpemented in WinXP and above.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Quote:
> I'm trying to write a script to join a computer to our Windows 2000
domain.
> I found the following code on MS's TechNet Script Center:

> ===== Begin code =====
> Const JOIN_DOMAIN             = 1
> Const ACCT_CREATE             = 2
> Const ACCT_DELETE             = 4
> Const WIN9X_UPGRADE           = 16
> Const DOMAIN_JOIN_IF_JOINED   = 32
> Const JOIN_UNSECURE           = 64
> Const MACHINE_PASSWORD_PASSED = 128
> Const DEFERRED_SPN_SET        = 256
> Const INSTALL_INVOCATION      = 262144

> strDomain   = "FABRIKAM"
> strPassword = "ls4k5ywA"
> strUser     = "shenalan"

> Set objNetwork = CreateObject("WScript.Network")
> strComputer = objNetwork.ComputerName

> Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\"
&
> _
>                    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='"
&
> _
>                    strComputer & "'")

> ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
>                                                 strPassword, _
>                                                 strDomain & "\" & strUser,
_
>                                                 NULL, _
>                                                 JOIN_DOMAIN + ACCT_CREATE)
> ===== End Code =====

> Looks great, but when I run it I get the message that the objComputer
> "doesn't support this property or method: 'JoinDomainOrWorkGroup'".

> Any ideas?

> Thanks,

> Tom



Tue, 14 Jun 2005 23:57:31 GMT  
 Join Computer to a Domain
Thanks for the information.  I'm running Win2K clients and servers.  Is
there a way to do it in Win2K?

Tom



Quote:

> That method is imlpemented in WinXP and above.



Wed, 15 Jun 2005 02:03:15 GMT  
 Join Computer to a Domain
There should be a netjoin.exe utility in the resource kit.

Otherwise a simple utility that forwards the command line params to the
NetJoinDomain API should to the trick

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Quote:
> Thanks for the information.  I'm running Win2K clients and servers.  Is
> there a way to do it in Win2K?

> Tom



> > That method is imlpemented in WinXP and above.



Wed, 15 Jun 2005 02:34:07 GMT  
 Join Computer to a Domain

Quote:

> Thanks for the information.  I'm running Win2K clients and servers.  Is
> there a way to do it in Win2K?

Hi

You can use the command line utility netdom.exe.

Latest version of netdom.exe can be downloaded from here:

Windows 2000 SP3 Support Tools
http://www.microsoft.com/windows2000/downloads/servicepacks/sp3/suppo...

There came one updated version with SP2 as well, but I would be very surprised
if the SP3 netdom version do not work on pre SP3 computers.

More info here as well:


Subject: Re: Join Workgroup then join domain, via WSH?
Newsgroups: microsoft.public.scripting.wsh
Date: 2002-09-09 14:03:29 PST
http://groups.google.com/groups?selm=3D7CFEC8.556EDB2B%40hydro.com

Note that netdom.exe needs to be run with an account that is member (directly or

indirectly) of the Administrators group on the local computer, unless using the
/UserO switch.

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Thu, 16 Jun 2005 01:49:23 GMT  
 Join Computer to a Domain


Fri, 19 Jun 1992 00:00:00 GMT  
 Join Computer to a Domain
Thanks, got netdom.  Now I can't get it to work.

I have a Win2K Pro computer that has been added to our Win2K AD domain.
When I try to 'netdom join' it to the domain I get a 'remote computer is not
available' message.  I get the same message when I try to 'netdom remove'
the workstation.  I think I'm reaching the DC because when I 'netdom add' I
get a message that the account already exists.  The /UserD id I'm using can
add workstations to the domain interactively and I'm logged on as the
built-in local administrator so that should satisfy the /UserO requirement.
Here's what I've been trying:

netdom join MyComputerName /d:MyDomainName.com /uD:MyID /pD:*

When I get it working I'm going to build it into a script that asks for the
/UserD and includes the /REBoot switch.

Running 'ipconfig -all' shows that I have all the correct settings (dhcp, 2
dns).  Our primary dns is Unix with our secondary (cache) being MS .  If I
hard-code the dns entries in the tcp/ip properties it makes no difference.

Any ideas why I'm getting the 'not available' messages?

Thanks,

Tom



Quote:

> > Thanks for the information.  I'm running Win2K clients and servers.  Is
> > there a way to do it in Win2K?

> Hi

> You can use the command line utility netdom.exe.

> Latest version of netdom.exe can be downloaded from here:

> Windows 2000 SP3 Support Tools

http://www.microsoft.com/windows2000/downloads/servicepacks/sp3/suppo...
..asp
Quote:

> There came one updated version with SP2 as well, but I would be very
surprised
> if the SP3 netdom version do not work on pre SP3 computers.

> More info here as well:


> Subject: Re: Join Workgroup then join domain, via WSH?
> Newsgroups: microsoft.public.scripting.wsh
> Date: 2002-09-09 14:03:29 PST
> http://groups.google.com/groups?selm=3D7CFEC8.556EDB2B%40hydro.com

> Note that netdom.exe needs to be run with an account that is member
(directly or

> indirectly) of the Administrators group on the local computer, unless
using the
> /UserO switch.

> --
> torgeir
> Microsoft MVP Scripting and WMI
> Porsgrunn Norway



Fri, 17 Jun 2005 22:34:36 GMT  
 Join Computer to a Domain

Quote:

> Thanks, got netdom.  Now I can't get it to work.

> I have a Win2K Pro computer that has been added to our Win2K AD domain.
> When I try to 'netdom join' it to the domain I get a 'remote computer is not
> available' message.  I get the same message when I try to 'netdom remove'
> the workstation.  I think I'm reaching the DC because when I 'netdom add' I
> get a message that the account already exists.  The /UserD id I'm using can
> add workstations to the domain interactively and I'm logged on as the
> built-in local administrator so that should satisfy the /UserO requirement.
> Here's what I've been trying:

> netdom join MyComputerName /d:MyDomainName.com /uD:MyID /pD:*

> When I get it working I'm going to build it into a script that asks for the
> /UserD and includes the /REBoot switch.

> Running 'ipconfig -all' shows that I have all the correct settings (dhcp, 2
> dns).  Our primary dns is Unix with our secondary (cache) being MS .  If I
> hard-code the dns entries in the tcp/ip properties it makes no difference.

> Any ideas why I'm getting the 'not available' messages?

Hi

The user has local administrator rights?

The Server service (LanmanServer) exists and is not disabled?

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Fri, 17 Jun 2005 23:14:11 GMT  
 Join Computer to a Domain
Server service did the trick.  We don't install that by default in our
environment.  Why does it need that?  I can put the same system on the
domain interactively without it.  Oh well, scripting the service
install/start/stop/uninstall should be relatively easy.

Thanks, again, Torgeir.  (It seems I never get done saying that to you -
either in a posting or just while I'm lurking!)



Quote:

> Hi

> The user has local administrator rights?

> The Server service (LanmanServer) exists and is not disabled?

> --
> torgeir
> Microsoft MVP Scripting and WMI
> Porsgrunn Norway



Fri, 17 Jun 2005 23:49:59 GMT  
 Join Computer to a Domain
In a nutshell,
the server service is used to "create" the IPC$ share,
that is uset to authenticate a SMB Session.
Since NetLogon uses RPC over named pipes,
you need an authenticated SMB Session first.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Quote:
> Server service did the trick.  We don't install that by default in our
> environment.  Why does it need that?  I can put the same system on the
> domain interactively without it.  Oh well, scripting the service
> install/start/stop/uninstall should be relatively easy.

> Thanks, again, Torgeir.  (It seems I never get done saying that to you -
> either in a posting or just while I'm lurking!)



> > Hi

> > The user has local administrator rights?

> > The Server service (LanmanServer) exists and is not disabled?

> > --
> > torgeir
> > Microsoft MVP Scripting and WMI
> > Porsgrunn Norway



Fri, 17 Jun 2005 23:59:42 GMT  
 Join Computer to a Domain

Quote:

> Server service did the trick.  We don't install that by default in our
> environment.  Why does it need that?  I can put the same system on the
> domain interactively without it.  Oh well, scripting the service
> install/start/stop/uninstall should be relatively easy.

Hi

Installing the server service is a bit tricky. Here is a way to do it:

Export the registry key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer

from a machine where the server service is running as it should, to a registry
file with e.g. the name Lanmansvr.reg

Then, on a computer with no server service installed, run the following two
command lines from e.g. a batch file (note that the rundll32 line will wrap in
the newsreader!):

%SystemRoot%\system32\rundll32.exe setupapi.dll,InstallHinfSection Install.ndi
132 %SystemRoot%\Inf\netserv.inf

regedit.exe /s "Lanmansvr.reg"

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Sat, 18 Jun 2005 00:37:02 GMT  
 Join Computer to a Domain
Torgeir,

Thanks for all your help.  Let me wrap this one up...

In order for me to join a Win2K computer that does not have the Server
service running to a domain then remove the Server service again all within
a script I need to:

1. Install the NetServ.inf with the RunDLL32 command
2. Batch Regedit to add the LMServer key details
3. Net Start the Server service
4. NetDom the workstation onto the domain
5. Net Stop the Server service
6. Batch Regedit to put the LMServer key back the way it was
7. Reboot

How about uninstalling the NetServ.inf?  Is that necessary?  How would I do
it?

Thanks, again.

Tom



Sat, 18 Jun 2005 04:08:58 GMT  
 Join Computer to a Domain

Quote:

> Torgeir,

> Thanks for all your help.  Let me wrap this one up...

> In order for me to join a Win2K computer that does not have the Server
> service running to a domain then remove the Server service again all within
> a script I need to:

> 1. Install the NetServ.inf with the RunDLL32 command
> 2. Batch Regedit to add the LMServer key details
> 3. Net Start the Server service
> 4. NetDom the workstation onto the domain
> 5. Net Stop the Server service
> 6. Batch Regedit to put the LMServer key back the way it was
> 7. Reboot

Step 6. is not a "valid" point really. You need to do 2. because NetServ.inf
doesn't create all necessary values under the LanmanServer key by some reason.
If you only run the NetServ.inf install and try to start the service, you will
get an error message.

Quote:
> How about uninstalling the NetServ.inf?  Is that necessary?

That is up to you to decide. An alternative is to disable it instead of deleting
it (we do).

Quote:
>  How would I do
> it?

After you have stopped the service, delete the LanmanServer registry key. This
delete can be done with a registry file:


Subject: Re: Batch use of regedit
Newsgroups: microsoft.public.win2000.general
http://groups.google.com/groups?selm=3D42A2F5.D3DDBE76%40hydro.com

--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway



Sat, 18 Jun 2005 04:33:47 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Add/join computer to Windows 2000 domain

2. Join Workgroup then join domain, via WSH?

3. HELP: Listing domains and computers in the domains

4. domain pruefen domain provider es domain registrieren domain angebot no domain

5. domaene sichern de tc domain domain registrieren preisvergleich kostenlose toplevel domain de domain preis

6. plesk domain anmeldung domaene langsam anmeldung an domain de domain kaufen domain suchen

7. Windows NT Machine, join Domain through VBS

8. Joining Domain and Verifying it ....

9. script to join domain.

10. Join Domain

11. Join Domain

12. Changing machine name and joining domain

 

 
Powered by phpBB® Forum Software