Operating System - Microsoft
1752815 Members
6246 Online
108789 Solutions
New Discussion юеВ

two instructions within a FOR

 
SOLVED
Go to solution
Edgar Zapata
Esteemed Contributor

two instructions within a FOR

I'm intereseted in determining if a list of some 300 servers are being rebooted on a weekly basis and when.

For that purpose, I am running the srvinfo within a FOR.

for /F %%a in (ServerList.txt) do srvinfo \\%%a >> outputFile.csv

After that, I perform the following:
findstr /C:"System Up Time" outputFile.csv >> rebootingTime.csv

This way, I get the following output line only:
System Up Time: 12 Days, 2 Hr, 50 Min, 7 Sec

The thing is there are some servers that cannot be contacted so I don't know which server is which.

What I need is having the servername in the outputfile as well.

I think it should be something like this (using the pipe |):

for /F %%a in (serverlist.txt) do echo %%a >> outputfile.csv | srvinfo \\%%a >> outputfile.csv

But this doesn't work.

Tnks.

2 REPLIES 2
Jon Finley
Honored Contributor
Solution

Re: two instructions within a FOR

You "should" be able to do the following:

for /F %%a in (serverlist.txt) do (
echo %%a >> outputfile.csv
srvinfo \\%%a >> outputfile.csv
)

Jon
"Do or do not. There is no try!" - Yoda
Edgar Zapata
Esteemed Contributor

Re: two instructions within a FOR

Tnks.
It did the trick.

Edgar.