Re: running scripts on multiple computers

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 04/25/04


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
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Question about objWMIService.ExecQuery
    ... > I'm just curious what type of variable is colLoggedEvents? ... can be found out by using two VBScript methods, ... info about WMI to make guesses - but it's generally useful for getting ... you can simply fast-forward through a loop iterating over the ...
    (microsoft.public.windows.server.scripting)
  • Re: Looping, How would I do this?
    ... Like I said you can use VBscript with the .cbp pages. ... provide a macro language for Hyperion Enterprise Reporting users. ... maximum flexibility when constructing scripts. ... So a FOR...NEXT loop in VBScript would be like this: ...
    (microsoft.public.scripting.vbscript)
  • Re: Object oriented
    ... but there will be a lot of wasted words if you have some or a lot of programming experience in some version of BASIC or any other programming language. ... Microsoft provides a wealth of objects that VBScript can access to do all the stuff you really want to do. ... Many, perhaps most, sample scripts in the help file are aimed at being used within a web page, not in a stand-alone script. ...
    (microsoft.public.scripting.vbscript)
  • Re: recursive grep problem [zip logs]
    ... assignments on stdout and run the whole bloody thing in an eval $). ... work off to customizable and hackable shell scripts (the customization ... Writing something to do globbing inbound sftp transfers, ... may hit that while loop with a SIGPIPE and terminate it when foo ends ...
    (uk.comp.os.linux)
  • Re: How to send data to a C# App from VBScript
    ... > VBScripts (also located on the file server) to which I would like the ... > and the scripts will never be ran w/o the application. ... I basically want to send status and such from the vbscript ... the parent process is by redirecting the standard output of the scripting engine. ...
    (microsoft.public.dotnet.languages.csharp)