Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get wmic to read a file with multiple hostnames and output who is logged on

$
0
0

I am looking for a way to get WMIC to read a file will a list of hostnames and to return the currently logged on user if any.

At the moment I am just using wmic /node: "hostname" COMPUTERSYSTEM GET USERNAME.

This works fine for a single system, I would like to do it for nine and have the output look as such

hostname username

hostname username

or 

hostname

username

Thanks

Solved it 

@echo off
for /f %%a in (hostnames.txt) do WMIC /NODE:%%a COMPUTERSYSTEM GET USERNAME
pause


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>