Re: running scripts on multiple computers
From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 04/25/04
- Next message: Mike: "Re: running scripts on multiple computers"
- Previous message: Jeff Cochran: "Re: How to get the Information like Network Adapter,RAM & OS VErsion etc of a Windows 2000 Server?"
- In reply to: Al Dunbar [MS-MVP]: "Re: running scripts on multiple computers"
- Next in thread: Mike: "Re: running scripts on multiple computers"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 25 Apr 2004 17:45:23 -0500
Hi,
The example VBScript program linked on this page uses WMI to deploy patches
to many computers listed in a text file:
http://www.rlmueller.net/PatchInstall.htm
The program is based on Microsoft KB 827227 (linked on the page above) and
shows how to read the names, connect to each computer, and perform something
(the machines must have WMI installed).
A program can use ADO to retrieve the names of all computers in the domain.
For example, the program linked below creates a text file with the
Distinguished Names of all users in the domain:
http://www.rlmueller.net/Create%20User%20List%202.htm
This program can be modified to instead produce a text file with the
Distinguished Names of all computer objects in the domain. Intead of the
filter statement:
strFilter = "(&(objectCategory=person)(objectClass=user))"
you would instead use:
strFilter = "(objectCategory=computer)"
If instead of the Distinguished Name you wanted the NT name (NetBIOS name)
of the computer, you would replace all instances of "distinguishedName" with
"sAMAccountName". This would modify the following two statements:
strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName;subtree"
strDN = objRecordSet.Fields("distinguishedName")
Alternatively, you could have the program retrieve the recordset of all
computer names, then instead of saving the names to a file, loop through the
recordset, connect to each computer, and perform something on each. You just
have to be prepared to handle all computer objects in your domain. You may
also have to account for machines not being online at the time the program
runs.
-- Richard Microsoft MVP Scripting and ADSI HilltopLab web site - http://www.rlmueller.net -- "Al Dunbar [MS-MVP]" <alan-no-drub-spam@hotmail.com> wrote in message news:ueoQTFwKEHA.1156@TK2MSFTNGP09.phx.gbl... > > "Patrick Reese" <patre01@necomputergroup.com> wrote in message > news:%23rPcnPvKEHA.3852@TK2MSFTNGP10.phx.gbl... > > Is there anything you can put in place of the computer name to make the > > script run on all computers in the domain? > > No. That is simply the name of a computer. It's not like filenames, where in > some contexts *.* is taken to mean all files (or each of them individually) > that match that wildcard. The reason this cannot work here is that there > would need to be a construct known to vbscript that was automatically AD > aware. In general, when you want to write scripts that work against external > databases (such as active directory) you generally have to create > corresponding objects and deal with the details programmatically. See your > WMI scripts for examples of how this generally works. > > > if not, how would I make a loop > > to run it on more than one computer? > > If you are using the typical "script center" scripts, then you are already > using loops - see the FOR and NEXT statements, which typically look like > this: > > for each objitem in collitems > ... > next > > All you need to do is to create a collection of items that happen to include > all of the computers in your domain. This could be done simply by creating a > file containing a list of their names, by enumerating the computers > container, or perhaps by doing an ADO query. > > But, before anyone gives you more hints, is the problem that you are > unfamiliar with ADSI and/or ADO, or is it that you are unfamiliar with > vbscript? > > /Al > > > > > > > "Al Dunbar [MS-MVP]" <alan-no-drub-spam@hotmail.com> wrote in message > > news:#yBCjZuKEHA.808@tk2msftngp13.phx.gbl... > > > > > > change the line from: > > > > > > strComputer = "." > > > > > > to: > > > > > > strComputer = "thecomputer" > > > > > > and it should run against the computer named. To run against all > computers > > > you would need a loop to run it against each one individually. > > > > > > /Al > > > > > > > > > > > >
- Next message: Mike: "Re: running scripts on multiple computers"
- Previous message: Jeff Cochran: "Re: How to get the Information like Network Adapter,RAM & OS VErsion etc of a Windows 2000 Server?"
- In reply to: Al Dunbar [MS-MVP]: "Re: running scripts on multiple computers"
- Next in thread: Mike: "Re: running scripts on multiple computers"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|