Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Operating System - Microsoft
cancel
Showing results for 
Search instead for 
Did you mean: 

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