Sorry about the title, I struggled to explain it in one line.
I have a simple script which gets a remote systems status, and returns the line which contains the total memory, and outputs it to a file:
systeminfo /s:HOSTNAME | findstr /C:"Total Physical Memory" >> "D:\All PCs\RAM_LOG.txt"
I have a text file which has all of the hostnames for every PC I want to check. How can I run this same command on each of the PC's in the text file, without having to make a batch file repeating this same line?
Also, If possible to also include the hostname in the log.
UPDATE: I have come up with this, I will test it soon.
for /F "tokens=*" %%A in ("D:\All Pcs\pclist.txt") do ( echo. echo %%A >> "D:\All PCs\RAM_LOG.txt" systeminfo /s:%%A | findstr /C:"Total Physical Memory" >> "D:\All PCs\RAM_LOG.txt" )