Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Need vbs script to add computer in the domaine (OU )

Reply
Thread Tools Display Modes

Need vbs script to add computer in the domaine (OU )

 
 
lolo1790
Guest
Posts: n/a

 
      09-08-2008
i need vbs script to add computer in domain (OU ) with user and password.
i need write each information in windows , is it possible, because i don't
find this script.

Thanks
 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      09-08-2008

"lolo1790" <> wrote in message
news:4086AD19-C251-44EE-945A-...
>i need vbs script to add computer in domain (OU ) with user and password.
> i need write each information in windows , is it possible, because i don't
> find this script.
>
> Thanks


I have used a script similar to below to join a computer to a domain. The
username and password are hardcoded, as are the domain and OU information:
============
' JoinDomain.vbs
' VBScript program to join a computer to a domain.
' The computer account is created in Active Directory.
' The computer must have XP or above.
' The AD must be W2k3 or above.
' See c:\Windows\debug\NetSetup.log for details.

Option Explicit

Dim strDomain, strUser, strPassword
Dim objNetwork, strComputer, objComputer, lngReturnValue
Dim strOU

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 = "MyDomain"
strPassword = "zXy321q$"
strUser = "administrator"
strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"

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

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

lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, strOU, _
JOIN_DOMAIN + ACCT_CREATE)

Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
lolo1790
Guest
Posts: n/a

 
      09-09-2008
Thanks you
i would like with interactive windows, i would write each parameter in
little windows like " domain " "user" and password.

Thanks.

"Richard Mueller [MVP]" wrote:

>
> "lolo1790" <> wrote in message
> news:4086AD19-C251-44EE-945A-...
> >i need vbs script to add computer in domain (OU ) with user and password.
> > i need write each information in windows , is it possible, because i don't
> > find this script.
> >
> > Thanks

>
> I have used a script similar to below to join a computer to a domain. The
> username and password are hardcoded, as are the domain and OU information:
> ============
> ' JoinDomain.vbs
> ' VBScript program to join a computer to a domain.
> ' The computer account is created in Active Directory.
> ' The computer must have XP or above.
> ' The AD must be W2k3 or above.
> ' See c:\Windows\debug\NetSetup.log for details.
>
> Option Explicit
>
> Dim strDomain, strUser, strPassword
> Dim objNetwork, strComputer, objComputer, lngReturnValue
> Dim strOU
>
> 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 = "MyDomain"
> strPassword = "zXy321q$"
> strUser = "administrator"
> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
>
> Set objNetwork = CreateObject("WScript.Network")
> strComputer = objNetwork.ComputerName
>
> Set objComputer = GetObject("winmgmts:" _
> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" & _
> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
> strComputer & "'")
>
> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
> strPassword, strDomain & "\" & strUser, strOU, _
> JOIN_DOMAIN + ACCT_CREATE)
>
> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

 
Reply With Quote
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      09-09-2008
You can use the InputBox function to prompt for information. For example (in
part):

strDomain = InputBox("Enter the NetBIOS name of the domain")
strUser = InputBox("Enter administrator name")
strPassword = InputBox("Enter password")
strOU = InputBox("Enter the DN of the OU where computer account created")

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
"lolo1790" <> wrote in message
news:F4556796-5178-4EF3-945F-...
> Thanks you
> i would like with interactive windows, i would write each parameter in
> little windows like " domain " "user" and password.
>
> Thanks.
>
> "Richard Mueller [MVP]" wrote:
>
>>
>> "lolo1790" <> wrote in message
>> news:4086AD19-C251-44EE-945A-...
>> >i need vbs script to add computer in domain (OU ) with user and
>> >password.
>> > i need write each information in windows , is it possible, because i
>> > don't
>> > find this script.
>> >
>> > Thanks

>>
>> I have used a script similar to below to join a computer to a domain. The
>> username and password are hardcoded, as are the domain and OU
>> information:
>> ============
>> ' JoinDomain.vbs
>> ' VBScript program to join a computer to a domain.
>> ' The computer account is created in Active Directory.
>> ' The computer must have XP or above.
>> ' The AD must be W2k3 or above.
>> ' See c:\Windows\debug\NetSetup.log for details.
>>
>> Option Explicit
>>
>> Dim strDomain, strUser, strPassword
>> Dim objNetwork, strComputer, objComputer, lngReturnValue
>> Dim strOU
>>
>> 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 = "MyDomain"
>> strPassword = "zXy321q$"
>> strUser = "administrator"
>> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
>>
>> Set objNetwork = CreateObject("WScript.Network")
>> strComputer = objNetwork.ComputerName
>>
>> Set objComputer = GetObject("winmgmts:" _
>> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" & _
>> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
>> strComputer & "'")
>>
>> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
>> strPassword, strDomain & "\" & strUser, strOU, _
>> JOIN_DOMAIN + ACCT_CREATE)
>>
>> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>>
>>



 
Reply With Quote
 
lolo1790
Guest
Posts: n/a

 
      09-09-2008
With the line "strOU = InputBox("Enter the DN of the OU where computer
account created") "

I don't know what to write because my OU is applications/platon but what
else form i must write in this box ?

Thanks


"Richard Mueller [MVP]" wrote:

> You can use the InputBox function to prompt for information. For example (in
> part):
>
> strDomain = InputBox("Enter the NetBIOS name of the domain")
> strUser = InputBox("Enter administrator name")
> strPassword = InputBox("Enter password")
> strOU = InputBox("Enter the DN of the OU where computer account created")
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
> "lolo1790" <> wrote in message
> news:F4556796-5178-4EF3-945F-...
> > Thanks you
> > i would like with interactive windows, i would write each parameter in
> > little windows like " domain " "user" and password.
> >
> > Thanks.
> >
> > "Richard Mueller [MVP]" wrote:
> >
> >>
> >> "lolo1790" <> wrote in message
> >> news:4086AD19-C251-44EE-945A-...
> >> >i need vbs script to add computer in domain (OU ) with user and
> >> >password.
> >> > i need write each information in windows , is it possible, because i
> >> > don't
> >> > find this script.
> >> >
> >> > Thanks
> >>
> >> I have used a script similar to below to join a computer to a domain. The
> >> username and password are hardcoded, as are the domain and OU
> >> information:
> >> ============
> >> ' JoinDomain.vbs
> >> ' VBScript program to join a computer to a domain.
> >> ' The computer account is created in Active Directory.
> >> ' The computer must have XP or above.
> >> ' The AD must be W2k3 or above.
> >> ' See c:\Windows\debug\NetSetup.log for details.
> >>
> >> Option Explicit
> >>
> >> Dim strDomain, strUser, strPassword
> >> Dim objNetwork, strComputer, objComputer, lngReturnValue
> >> Dim strOU
> >>
> >> 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 = "MyDomain"
> >> strPassword = "zXy321q$"
> >> strUser = "administrator"
> >> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
> >>
> >> Set objNetwork = CreateObject("WScript.Network")
> >> strComputer = objNetwork.ComputerName
> >>
> >> Set objComputer = GetObject("winmgmts:" _
> >> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" & _
> >> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
> >> strComputer & "'")
> >>
> >> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
> >> strPassword, strDomain & "\" & strUser, strOU, _
> >> JOIN_DOMAIN + ACCT_CREATE)
> >>
> >> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
> >>
> >> --
> >> Richard Mueller
> >> MVP Directory Services
> >> Hilltop Lab - http://www.rlmueller.net
> >> --
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      09-09-2008
You must use the Distinguished Name (DN) of the Organizational Unit. This is
the only value that is sure to uniquely identify the OU. For example, the
value might be similar to:

ou=Sales,ou=West,dc=MyDomain,dc=com

It might be possible to have the script construct the DN from the Relative
Distinguished Name (RDN) of the OU, but that's a bit risky. The RDN in my
example above is "Sales", but that is not enough information in this case to
identify the OU. If, however, you know that the OU is at the root of the
domain (the OU is not a child of another OU, as in my example), the script
could determine the DNS name of the domain ("dc=MyDomain,dc=com" in my
example) from the RootDSE object and construct the DN of the OU from the
RDN. For example:
==========
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

strRDN = InputBox("Enter name of the OU")
strOU = "ou=" & strRDN & "," & strDNSDomain
=========
Otherwise, you must either know the Distinguished Name of the OU or hard
code the value in the script.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"lolo1790" <> wrote in message
news:763DD849-483D-4463-BB8B-...
> With the line "strOU = InputBox("Enter the DN of the OU where computer
> account created") "
>
> I don't know what to write because my OU is applications/platon but what
> else form i must write in this box ?
>
> Thanks
>
>
> "Richard Mueller [MVP]" wrote:
>
>> You can use the InputBox function to prompt for information. For example
>> (in
>> part):
>>
>> strDomain = InputBox("Enter the NetBIOS name of the domain")
>> strUser = InputBox("Enter administrator name")
>> strPassword = InputBox("Enter password")
>> strOU = InputBox("Enter the DN of the OU where computer account created")
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>> "lolo1790" <> wrote in message
>> news:F4556796-5178-4EF3-945F-...
>> > Thanks you
>> > i would like with interactive windows, i would write each parameter in
>> > little windows like " domain " "user" and password.
>> >
>> > Thanks.
>> >
>> > "Richard Mueller [MVP]" wrote:
>> >
>> >>
>> >> "lolo1790" <> wrote in message
>> >> news:4086AD19-C251-44EE-945A-...
>> >> >i need vbs script to add computer in domain (OU ) with user and
>> >> >password.
>> >> > i need write each information in windows , is it possible, because i
>> >> > don't
>> >> > find this script.
>> >> >
>> >> > Thanks
>> >>
>> >> I have used a script similar to below to join a computer to a domain.
>> >> The
>> >> username and password are hardcoded, as are the domain and OU
>> >> information:
>> >> ============
>> >> ' JoinDomain.vbs
>> >> ' VBScript program to join a computer to a domain.
>> >> ' The computer account is created in Active Directory.
>> >> ' The computer must have XP or above.
>> >> ' The AD must be W2k3 or above.
>> >> ' See c:\Windows\debug\NetSetup.log for details.
>> >>
>> >> Option Explicit
>> >>
>> >> Dim strDomain, strUser, strPassword
>> >> Dim objNetwork, strComputer, objComputer, lngReturnValue
>> >> Dim strOU
>> >>
>> >> 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 = "MyDomain"
>> >> strPassword = "zXy321q$"
>> >> strUser = "administrator"
>> >> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
>> >>
>> >> Set objNetwork = CreateObject("WScript.Network")
>> >> strComputer = objNetwork.ComputerName
>> >>
>> >> Set objComputer = GetObject("winmgmts:" _
>> >> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" &
>> >> _
>> >> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
>> >> strComputer & "'")
>> >>
>> >> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
>> >> strPassword, strDomain & "\" & strUser, strOU, _
>> >> JOIN_DOMAIN + ACCT_CREATE)
>> >>
>> >> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
>> >>
>> >> --
>> >> Richard Mueller
>> >> MVP Directory Services
>> >> Hilltop Lab - http://www.rlmueller.net
>> >> --
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
lolo1790
Guest
Posts: n/a

 
      09-10-2008
See my domain

in fact it's like that

"OU=Platon,ou=Applications,dc=adint,dc=imr,dc=fran cetelecom,dc=com"

So in the last box i must write all this information or only
"OU=Platon,ou=Applications "

Thanks

"Richard Mueller [MVP]" wrote:

> You must use the Distinguished Name (DN) of the Organizational Unit. This is
> the only value that is sure to uniquely identify the OU. For example, the
> value might be similar to:
>
> ou=Sales,ou=West,dc=MyDomain,dc=com
>
> It might be possible to have the script construct the DN from the Relative
> Distinguished Name (RDN) of the OU, but that's a bit risky. The RDN in my
> example above is "Sales", but that is not enough information in this case to
> identify the OU. If, however, you know that the OU is at the root of the
> domain (the OU is not a child of another OU, as in my example), the script
> could determine the DNS name of the domain ("dc=MyDomain,dc=com" in my
> example) from the RootDSE object and construct the DN of the OU from the
> RDN. For example:
> ==========
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strDNSDomain = objRootDSE.Get("defaultNamingContext")
>
> strRDN = InputBox("Enter name of the OU")
> strOU = "ou=" & strRDN & "," & strDNSDomain
> =========
> Otherwise, you must either know the Distinguished Name of the OU or hard
> code the value in the script.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "lolo1790" <> wrote in message
> news:763DD849-483D-4463-BB8B-...
> > With the line "strOU = InputBox("Enter the DN of the OU where computer
> > account created") "
> >
> > I don't know what to write because my OU is applications/platon but what
> > else form i must write in this box ?
> >
> > Thanks
> >
> >
> > "Richard Mueller [MVP]" wrote:
> >
> >> You can use the InputBox function to prompt for information. For example
> >> (in
> >> part):
> >>
> >> strDomain = InputBox("Enter the NetBIOS name of the domain")
> >> strUser = InputBox("Enter administrator name")
> >> strPassword = InputBox("Enter password")
> >> strOU = InputBox("Enter the DN of the OU where computer account created")
> >>
> >> --
> >> Richard Mueller
> >> MVP Directory Services
> >> Hilltop Lab - http://www.rlmueller.net
> >> --
> >> "lolo1790" <> wrote in message
> >> news:F4556796-5178-4EF3-945F-...
> >> > Thanks you
> >> > i would like with interactive windows, i would write each parameter in
> >> > little windows like " domain " "user" and password.
> >> >
> >> > Thanks.
> >> >
> >> > "Richard Mueller [MVP]" wrote:
> >> >
> >> >>
> >> >> "lolo1790" <> wrote in message
> >> >> news:4086AD19-C251-44EE-945A-...
> >> >> >i need vbs script to add computer in domain (OU ) with user and
> >> >> >password.
> >> >> > i need write each information in windows , is it possible, because i
> >> >> > don't
> >> >> > find this script.
> >> >> >
> >> >> > Thanks
> >> >>
> >> >> I have used a script similar to below to join a computer to a domain.
> >> >> The
> >> >> username and password are hardcoded, as are the domain and OU
> >> >> information:
> >> >> ============
> >> >> ' JoinDomain.vbs
> >> >> ' VBScript program to join a computer to a domain.
> >> >> ' The computer account is created in Active Directory.
> >> >> ' The computer must have XP or above.
> >> >> ' The AD must be W2k3 or above.
> >> >> ' See c:\Windows\debug\NetSetup.log for details.
> >> >>
> >> >> Option Explicit
> >> >>
> >> >> Dim strDomain, strUser, strPassword
> >> >> Dim objNetwork, strComputer, objComputer, lngReturnValue
> >> >> Dim strOU
> >> >>
> >> >> 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 = "MyDomain"
> >> >> strPassword = "zXy321q$"
> >> >> strUser = "administrator"
> >> >> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
> >> >>
> >> >> Set objNetwork = CreateObject("WScript.Network")
> >> >> strComputer = objNetwork.ComputerName
> >> >>
> >> >> Set objComputer = GetObject("winmgmts:" _
> >> >> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" &
> >> >> _
> >> >> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
> >> >> strComputer & "'")
> >> >>
> >> >> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
> >> >> strPassword, strDomain & "\" & strUser, strOU, _
> >> >> JOIN_DOMAIN + ACCT_CREATE)
> >> >>
> >> >> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
> >> >>
> >> >> --
> >> >> Richard Mueller
> >> >> MVP Directory Services
> >> >> Hilltop Lab - http://www.rlmueller.net
> >> >> --
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
lolo1790
Guest
Posts: n/a

 
      09-10-2008
i have a message ""returnvalue=87", what is this message ?

Thanks.

"Richard Mueller [MVP]" wrote:

> You must use the Distinguished Name (DN) of the Organizational Unit. This is
> the only value that is sure to uniquely identify the OU. For example, the
> value might be similar to:
>
> ou=Sales,ou=West,dc=MyDomain,dc=com
>
> It might be possible to have the script construct the DN from the Relative
> Distinguished Name (RDN) of the OU, but that's a bit risky. The RDN in my
> example above is "Sales", but that is not enough information in this case to
> identify the OU. If, however, you know that the OU is at the root of the
> domain (the OU is not a child of another OU, as in my example), the script
> could determine the DNS name of the domain ("dc=MyDomain,dc=com" in my
> example) from the RootDSE object and construct the DN of the OU from the
> RDN. For example:
> ==========
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strDNSDomain = objRootDSE.Get("defaultNamingContext")
>
> strRDN = InputBox("Enter name of the OU")
> strOU = "ou=" & strRDN & "," & strDNSDomain
> =========
> Otherwise, you must either know the Distinguished Name of the OU or hard
> code the value in the script.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "lolo1790" <> wrote in message
> news:763DD849-483D-4463-BB8B-...
> > With the line "strOU = InputBox("Enter the DN of the OU where computer
> > account created") "
> >
> > I don't know what to write because my OU is applications/platon but what
> > else form i must write in this box ?
> >
> > Thanks
> >
> >
> > "Richard Mueller [MVP]" wrote:
> >
> >> You can use the InputBox function to prompt for information. For example
> >> (in
> >> part):
> >>
> >> strDomain = InputBox("Enter the NetBIOS name of the domain")
> >> strUser = InputBox("Enter administrator name")
> >> strPassword = InputBox("Enter password")
> >> strOU = InputBox("Enter the DN of the OU where computer account created")
> >>
> >> --
> >> Richard Mueller
> >> MVP Directory Services
> >> Hilltop Lab - http://www.rlmueller.net
> >> --
> >> "lolo1790" <> wrote in message
> >> news:F4556796-5178-4EF3-945F-...
> >> > Thanks you
> >> > i would like with interactive windows, i would write each parameter in
> >> > little windows like " domain " "user" and password.
> >> >
> >> > Thanks.
> >> >
> >> > "Richard Mueller [MVP]" wrote:
> >> >
> >> >>
> >> >> "lolo1790" <> wrote in message
> >> >> news:4086AD19-C251-44EE-945A-...
> >> >> >i need vbs script to add computer in domain (OU ) with user and
> >> >> >password.
> >> >> > i need write each information in windows , is it possible, because i
> >> >> > don't
> >> >> > find this script.
> >> >> >
> >> >> > Thanks
> >> >>
> >> >> I have used a script similar to below to join a computer to a domain.
> >> >> The
> >> >> username and password are hardcoded, as are the domain and OU
> >> >> information:
> >> >> ============
> >> >> ' JoinDomain.vbs
> >> >> ' VBScript program to join a computer to a domain.
> >> >> ' The computer account is created in Active Directory.
> >> >> ' The computer must have XP or above.
> >> >> ' The AD must be W2k3 or above.
> >> >> ' See c:\Windows\debug\NetSetup.log for details.
> >> >>
> >> >> Option Explicit
> >> >>
> >> >> Dim strDomain, strUser, strPassword
> >> >> Dim objNetwork, strComputer, objComputer, lngReturnValue
> >> >> Dim strOU
> >> >>
> >> >> 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 = "MyDomain"
> >> >> strPassword = "zXy321q$"
> >> >> strUser = "administrator"
> >> >> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
> >> >>
> >> >> Set objNetwork = CreateObject("WScript.Network")
> >> >> strComputer = objNetwork.ComputerName
> >> >>
> >> >> Set objComputer = GetObject("winmgmts:" _
> >> >> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\" &
> >> >> _
> >> >> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
> >> >> strComputer & "'")
> >> >>
> >> >> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
> >> >> strPassword, strDomain & "\" & strUser, strOU, _
> >> >> JOIN_DOMAIN + ACCT_CREATE)
> >> >>
> >> >> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
> >> >>
> >> >> --
> >> >> Richard Mueller
> >> >> MVP Directory Services
> >> >> Hilltop Lab - http://www.rlmueller.net
> >> >> --
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      09-11-2008
I doubt anyone knows what the numbers mean. Check the log file at:

c:\Windows\debug\NetSetup.log

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"lolo1790" <> wrote in message
news:EB6FE9AC-B347-4DD9-93DA-...
>i have a message ""returnvalue=87", what is this message ?
>
> Thanks.
>
> "Richard Mueller [MVP]" wrote:
>
>> You must use the Distinguished Name (DN) of the Organizational Unit. This
>> is
>> the only value that is sure to uniquely identify the OU. For example, the
>> value might be similar to:
>>
>> ou=Sales,ou=West,dc=MyDomain,dc=com
>>
>> It might be possible to have the script construct the DN from the
>> Relative
>> Distinguished Name (RDN) of the OU, but that's a bit risky. The RDN in my
>> example above is "Sales", but that is not enough information in this case
>> to
>> identify the OU. If, however, you know that the OU is at the root of the
>> domain (the OU is not a child of another OU, as in my example), the
>> script
>> could determine the DNS name of the domain ("dc=MyDomain,dc=com" in my
>> example) from the RootDSE object and construct the DN of the OU from the
>> RDN. For example:
>> ==========
>> Set objRootDSE = GetObject("LDAP://RootDSE")
>> strDNSDomain = objRootDSE.Get("defaultNamingContext")
>>
>> strRDN = InputBox("Enter name of the OU")
>> strOU = "ou=" & strRDN & "," & strDNSDomain
>> =========
>> Otherwise, you must either know the Distinguished Name of the OU or hard
>> code the value in the script.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>> "lolo1790" <> wrote in message
>> news:763DD849-483D-4463-BB8B-...
>> > With the line "strOU = InputBox("Enter the DN of the OU where computer
>> > account created") "
>> >
>> > I don't know what to write because my OU is applications/platon but
>> > what
>> > else form i must write in this box ?
>> >
>> > Thanks
>> >
>> >
>> > "Richard Mueller [MVP]" wrote:
>> >
>> >> You can use the InputBox function to prompt for information. For
>> >> example
>> >> (in
>> >> part):
>> >>
>> >> strDomain = InputBox("Enter the NetBIOS name of the domain")
>> >> strUser = InputBox("Enter administrator name")
>> >> strPassword = InputBox("Enter password")
>> >> strOU = InputBox("Enter the DN of the OU where computer account
>> >> created")
>> >>
>> >> --
>> >> Richard Mueller
>> >> MVP Directory Services
>> >> Hilltop Lab - http://www.rlmueller.net
>> >> --
>> >> "lolo1790" <> wrote in message
>> >> news:F4556796-5178-4EF3-945F-...
>> >> > Thanks you
>> >> > i would like with interactive windows, i would write each parameter
>> >> > in
>> >> > little windows like " domain " "user" and password.
>> >> >
>> >> > Thanks.
>> >> >
>> >> > "Richard Mueller [MVP]" wrote:
>> >> >
>> >> >>
>> >> >> "lolo1790" <> wrote in message
>> >> >> news:4086AD19-C251-44EE-945A-...
>> >> >> >i need vbs script to add computer in domain (OU ) with user and
>> >> >> >password.
>> >> >> > i need write each information in windows , is it possible,
>> >> >> > because i
>> >> >> > don't
>> >> >> > find this script.
>> >> >> >
>> >> >> > Thanks
>> >> >>
>> >> >> I have used a script similar to below to join a computer to a
>> >> >> domain.
>> >> >> The
>> >> >> username and password are hardcoded, as are the domain and OU
>> >> >> information:
>> >> >> ============
>> >> >> ' JoinDomain.vbs
>> >> >> ' VBScript program to join a computer to a domain.
>> >> >> ' The computer account is created in Active Directory.
>> >> >> ' The computer must have XP or above.
>> >> >> ' The AD must be W2k3 or above.
>> >> >> ' See c:\Windows\debug\NetSetup.log for details.
>> >> >>
>> >> >> Option Explicit
>> >> >>
>> >> >> Dim strDomain, strUser, strPassword
>> >> >> Dim objNetwork, strComputer, objComputer, lngReturnValue
>> >> >> Dim strOU
>> >> >>
>> >> >> 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 = "MyDomain"
>> >> >> strPassword = "zXy321q$"
>> >> >> strUser = "administrator"
>> >> >> strOU = "ou=Computers,ou=West,dc=MyDomain,dc=com"
>> >> >>
>> >> >> Set objNetwork = CreateObject("WScript.Network")
>> >> >> strComputer = objNetwork.ComputerName
>> >> >>
>> >> >> Set objComputer = GetObject("winmgmts:" _
>> >> >> & "{impersonationLevel=Impersonate,authenticationLev el=Pkt}!\\"
>> >> >> &
>> >> >> _
>> >> >> strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
>> >> >> strComputer & "'")
>> >> >>
>> >> >> lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
>> >> >> strPassword, strDomain & "\" & strUser, strOU, _
>> >> >> JOIN_DOMAIN + ACCT_CREATE)
>> >> >>
>> >> >> Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
>> >> >>
>> >> >> --
>> >> >> Richard Mueller
>> >> >> MVP Directory Services
>> >> >> Hilltop Lab - http://www.rlmueller.net
>> >> >> --
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Adding AD to domaine Jean Paul Mertens Windows Small Business Server 4 07-14-2008 11:21 AM
Config d'utilisateurs d'un domaine sur un portable déconnecté du domaine Yrrreth Windows Small Business Server 1 04-19-2006 08:30 AM
policie on the domaine 2003 osiris64 Active Directory 2 02-07-2006 03:59 AM
Join W2k3 to Domaine Active Directory 2 02-11-2005 04:58 AM
Join profile with Computer to Domaine Active Directory 2 01-13-2005 09:09 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59