CMD Script: Run Task against Every Domain Controller

Discussion in 'Scripting' started by anonymous, Jan 23, 2006.

  1. anonymous

    anonymous Guest

    Hi,

    I'd like to know if it is possible to do the following in a CMD Shell
    script.

    For each DomainController in DomainControllers OU

    Domain Controller = X

    run task on X

    next


    Basically to enumerate the Domain Controllers in a domain and run a remote
    command against each one.




    Thx
     
    anonymous, Jan 23, 2006
    #1
    1. Advertisements

  2. to list all domaincontrollers on XP / 2003 you can use :

    dsquery server /o rdn

    For a good VBscript example to list the Domaincontrollers,
    see Richard L. Mueller's site :

    http://www.rlmueller.net/Enumerate DCs.htm

    a MSH example I will post on my blog today ;-)

    you can use that list to connect to the DC's and run a command.

    gr /\/\o\/\/
     
    /\/\o\/\/ [MVP], Jan 23, 2006
    #2
    1. Advertisements

  3. Hi,

    Many tasks can be done remotely, perhaps using the Run method of the
    wshShell object. If, however, you need to run an executable on the remote
    machine, you will need to use WMI to copy the executable to the machine and
    run it.

    I have an example VBScript program to deploy patches to machines listed in a
    text file linked here:

    http://www.rlmueller.net/PatchInstall.htm

    Such a program is no longer needed with WSUS, but it demonstrates how to
    copy the file, run it, wait for execution to complete, and delete the file.
    The operation is repeated on each computer designated in a text file. You
    could instead use EnumerateDCs.vbs and loop through the recordset of Domain
    Controllers.
     
    Richard Mueller, Jan 23, 2006
    #3
  4. anonymous

    anonymous Guest

    Interesting script Richard, I will have to take a look at the Win32_Process
    stuff - it looks useful.
     
    anonymous, Jan 23, 2006
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.