Re: Joing computer script
- From: "Bobby" <blh_24@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 23 Jun 2005 16:48:42 -0400
Thanks for your help Corey. Whew!! Scripts look forgein to me, as I have no
experince. I have a site that has over 100 computers to join to the domain
in a few weeks. I wanted something simple to make it easier on me. I'm just
afraid that I would spend more time trying to get this to work.
"Corey_H" <corey_hatch@xxxxxxxxxxx> wrote in message
news:1119552846.276644.8140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Bobby,
This script, as written, has to be run locally from the machine to be
joined to the domain. If you can connect to machines by hostname (you
can translate a computername to an IP address - can test by just typing
ping <machinename> in a command line), then you can adjust the script
like below. The input can also be a text file (which probably makes
more sense and you can simply read in the machines one at a time) as
shown in the 2nd example. Here you'd have to have a text file
("workstations.txt") with one workstation per line...
--Example One
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
strDomain = "Domain Name"
strPassword = "Password that can Join 2 domain"
strUser = "User that can join 2 domain"
arrayComputers = (computer1, computer2, computer3,.........)
For x= 0 to UBound(arrayComputers)
strComputer = arrayComputers(x)
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)
Next
--Example 2
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
strDomain = "Domain Name"
strPassword = "Password that can Join 2 domain"
strUser = "User that can join 2 domain"
set fsi = CreateObject("Scripting.FileSystemObject")
Set inStream = fsi.OpenTextFile("Workstations.txt")
'Loop through text file entries
do while not inStream.AtEndOfStream
strComputer = inStream.ReadLine
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)
Loop
.
- References:
- Joing computer script
- From: Bobby
- Re: Joing computer script
- From: Corey_H
- Re: Joing computer script
- From: Bobby
- Re: Joing computer script
- From: Corey_H
- Joing computer script
- Prev by Date: Re: Checking services on remote machine
- Next by Date: Comma in AD object name is causing error
- Previous by thread: Re: Joing computer script
- Next by thread: Using VB Script to install software - Need insight -
- Index(es):
Relevant Pages
|