PC Review


Reply
Thread Tools Rate Thread

CMD Script: Run Task against Every Domain Controller

 
 
anonymous
Guest
Posts: n/a
 
      23rd Jan 2006
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?L1wvXG9cL1wvIFtNVlBd?=
Guest
Posts: n/a
 
      23rd Jan 2006
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%20DCs.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\/\/


"anonymous" wrote:

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

 
Reply With Quote
 
Richard Mueller
Guest
Posts: n/a
 
      23rd Jan 2006
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
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
news:701B49BB-1460-4326-8FE8-(E-Mail Removed)...
> 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%20DCs.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\/\/
>
>
> "anonymous" wrote:
>
>> 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
>>
>>
>>



 
Reply With Quote
 
anonymous
Guest
Posts: n/a
 
      23rd Jan 2006
I am aware of both dsquery and VBScript methods. Havent really looked at the
MSH stuff yet :-)

I was kinda hoping to get something in a .CMD file - something along the
lines of the following script translated into cmd shell script.


Set objDCsOU = GetObject(LDAP://OU=Domain Controllers,DC=mydomain,DC=com)

for each objDC in objDCsOU

strDC = objDC.cn

wshShell.exec "repadmin /kcc " & strDC

next


Thanks anyway




"Richard Mueller" <rlmueller-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
> "/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
> news:701B49BB-1460-4326-8FE8-(E-Mail Removed)...
>> 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%20DCs.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\/\/
>>
>>
>> "anonymous" wrote:
>>
>>> 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
>>>
>>>
>>>

>
>



 
Reply With Quote
 
/\\/\\o\\/\\/ [MVP]
Guest
Posts: n/a
 
      23rd Jan 2006
you can do it like this in CMD :

for /f %%i in ('dsquery server /o rdn') do call oSomething %%i

goto :EOF

oSomething

echo %1

goto :EOF

gr /\/\o\/\/

anonymous wrote:
> I am aware of both dsquery and VBScript methods. Havent really looked at the
> MSH stuff yet :-)
>
> I was kinda hoping to get something in a .CMD file - something along the
> lines of the following script translated into cmd shell script.
>
>
> Set objDCsOU = GetObject(LDAP://OU=Domain Controllers,DC=mydomain,DC=com)
>
> for each objDC in objDCsOU
>
> strDC = objDC.cn
>
> wshShell.exec "repadmin /kcc " & strDC
>
> next
>
>
> Thanks anyway
>
>
>
>
> "Richard Mueller" <rlmueller-(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>>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
>>Microsoft MVP Scripting and ADSI
>>Hilltop Lab - http://www.rlmueller.net
>>
>>"/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
>>news:701B49BB-1460-4326-8FE8-(E-Mail Removed)...
>>
>>>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%20DCs.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\/\/
>>>
>>>
>>>"anonymous" wrote:
>>>
>>>
>>>>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
>>>>
>>>>
>>>>

>>
>>

>
>

 
Reply With Quote
 
anonymous
Guest
Posts: n/a
 
      23rd Jan 2006
Thats great, thanks. It will be a good script template to use.


"/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> you can do it like this in CMD :
>
> for /f %%i in ('dsquery server /o rdn') do call oSomething %%i
>
> goto :EOF
>
> oSomething
>
> echo %1
>
> goto :EOF
>
> gr /\/\o\/\/
>
> anonymous wrote:
>> I am aware of both dsquery and VBScript methods. Havent really looked at
>> the MSH stuff yet :-)
>>
>> I was kinda hoping to get something in a .CMD file - something along the
>> lines of the following script translated into cmd shell script.
>>
>>
>> Set objDCsOU = GetObject(LDAP://OU=Domain Controllers,DC=mydomain,DC=com)
>>
>> for each objDC in objDCsOU
>>
>> strDC = objDC.cn
>>
>> wshShell.exec "repadmin /kcc " & strDC
>>
>> next
>>
>>
>> Thanks anyway
>>
>>
>>
>>
>> "Richard Mueller" <rlmueller-(E-Mail Removed)> wrote in
>> message news:%(E-Mail Removed)...
>>
>>>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
>>>Microsoft MVP Scripting and ADSI
>>>Hilltop Lab - http://www.rlmueller.net
>>>
>>>"/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
>>>news:701B49BB-1460-4326-8FE8-(E-Mail Removed)...
>>>
>>>>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%20DCs.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\/\/
>>>>
>>>>
>>>>"anonymous" wrote:
>>>>
>>>>
>>>>>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
>>>>>
>>>>>
>>>>>
>>>
>>>

>>


 
Reply With Quote
 
anonymous
Guest
Posts: n/a
 
      23rd Jan 2006
Interesting script Richard, I will have to take a look at the Win32_Process
stuff - it looks useful.



"Richard Mueller" <rlmueller-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
> "/\/\o\/\/ [MVP]" <(E-Mail Removed)> wrote in message
> news:701B49BB-1460-4326-8FE8-(E-Mail Removed)...
>> 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%20DCs.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\/\/
>>
>>
>> "anonymous" wrote:
>>
>>> 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
>>>
>>>
>>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
howto promote additional domain controller to domain controller anisetti.sureshbabu@gmail.com Microsoft Windows 2000 Active Directory 4 11th Apr 2007 04:49 PM
Reference Domain Controller in Script peter stickney Microsoft Windows 2000 Active Directory 1 7th Mar 2007 12:28 AM
Convert Primary Domain Controller to a Child Domain Controller. Joe Microsoft Windows 2000 Active Directory 0 27th Mar 2006 07:32 PM
script to add users to win2k domain controller hh Microsoft Windows 2000 CMD Promt 1 26th Nov 2003 10:25 PM
Domain controller dies and 2nd domain controller isn't picking up the slack Iggy Microsoft Windows 2000 Active Directory 6 21st Nov 2003 04:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 PM.