Run a command against a set of servers


H

Hassan

I want to be able to run a command against a set of servers.

Say I have 4 servers

ServerA, ServerB,ServerC and ServerD

So I want to run a command such as

msinfo32 /computer [ServerName]

where servername would be those 4 servers. Can you just provide a generic
script for me that i could use?

Pseudo code

For { List of Servers}
do
{command [Servername]}

I just want to get started and I hope to add on to whatever example you can
provide..

Thanks
 
Ad

Advertisements

P

Pegasus \(MVP\)

Hassan said:
I want to be able to run a command against a set of servers.

Say I have 4 servers

ServerA, ServerB,ServerC and ServerD

So I want to run a command such as

msinfo32 /computer [ServerName]

where servername would be those 4 servers. Can you just provide a generic
script for me that i could use?

Pseudo code

For { List of Servers}
do
{command [Servername]}

I just want to get started and I hope to add on to whatever example you can
provide..

Thanks

Try this:

for %a in (Server1 Server2 Server3 Server4) do msinfo32 /computer %a
(from a Command Prompt)

@echo off
for %%a in (Server1 Server2 Server3 Server4) do msinfo32 /computer %%a
(in a batch file)

@echo off
for /F %%a in (c:\Servers.txt) do msinfo32 /computer %%a
(Reading server names from a list file)
(from a Command Prompt)
 
Ad

Advertisements

H

Hassan

Cool.. Will give that a shot.. thats a good start for me..


Pegasus (MVP) said:
Hassan said:
I want to be able to run a command against a set of servers.

Say I have 4 servers

ServerA, ServerB,ServerC and ServerD

So I want to run a command such as

msinfo32 /computer [ServerName]

where servername would be those 4 servers. Can you just provide a generic
script for me that i could use?

Pseudo code

For { List of Servers}
do
{command [Servername]}

I just want to get started and I hope to add on to whatever example you can
provide..

Thanks

Try this:

for %a in (Server1 Server2 Server3 Server4) do msinfo32 /computer %a
(from a Command Prompt)

@echo off
for %%a in (Server1 Server2 Server3 Server4) do msinfo32 /computer %%a
(in a batch file)

@echo off
for /F %%a in (c:\Servers.txt) do msinfo32 /computer %%a
(Reading server names from a list file)
(from a Command Prompt)
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top