Re: Joing computer script



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:{impersona­tionLevel=Impersonate}!\\" & _
strComputer &
"\root\cimv2:Win32_ComputerSys­tem.Name='" & _
strComputer & "'")


ReturnValue = objComputer.JoinDomainOrWorkGr­oup(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:{impersona­tionLevel=Impersonate}!\\" & _
strComputer &
"\root\cimv2:Win32_ComputerSys­tem.Name='" & _
strComputer & "'")


ReturnValue = objComputer.JoinDomainOrWorkGr­oup(strDomain, _
strPassword, _
strDomain & "\" &
strUser, _
NULL, _
JOIN_DOMAIN +
ACCT_CREATE)

Loop


.



Relevant Pages

  • Re: Newbie Here-Installing Flash on 50 machines
    ... machines to deploy to, and handle cases where machines are off line. ... a generic script really has no way to tell which computers ... Macromedia does provide a Windows MSI installer for the Flash ...
    (microsoft.public.windows.server.scripting)
  • RE: Reboot Script for Group Policy?
    ... Thanks for the reply and modification you made to the script you provided. ... Machines Names/IP and time should be separated by ... > 'Script to REBOOT a machine remotely... ... >>> I have a script that I use to reboot remote computers. ...
    (microsoft.public.windows.server.scripting)
  • Re: Only logon to computers in 1 OU
    ... I don't want to add computers in AD and then have to Add and Delete ... one user) needs access to the machines? ... script it or link a GP with the "Deny log on locally" security setting ...
    (microsoft.public.win2000.group_policy)
  • RE: Changing local admin PW using vb logon script - can it be encrypted?
    ... Chwinpw is a small command line utility that can securely change passwords on remote/local windows ... be run from a logon script or from a central location. ... against all of the computers you want ... > machines run the script. ...
    (Focus-Microsoft)
  • Re: Joing computer script
    ... This script, as written, has to be run locally from the machine to be ... If you can connect to machines by hostname (you ... Set objComputer = ... 'Loop through text file entries ...
    (microsoft.public.scripting.vbscript)