Thursday, 19 March 2015

scan machines on the domain to see who is logged in

I got frustrated with not being able to find out who is logged into which computer on the 100's of customer domains we look after so wrote a little script to do it. I know of how to do it with a single computer, but who wants that half the time?

Use ADTidy to get a list of computers, or csvde or whatever you want, I like ADTidy. Remember to filter out those you don't want and change the column to just Name, export to csv, rename csv to .txt and do a find and replace for double quotes " leaving the replace field as empty to remove all the quotes.

copy and paste this into a text file and save as a .bat

for /f "delims=" %%x in (list.csv) do echo %%x >> list.txt |  qwinsta /server:%%x >> list.txt

Or you could even do it on IP's with the below, it will display the last octet of the IP as you will know the range its scanning, or alter it to include the full IP - I'll let you figure that out ;-)

 for /L %%x in (1,1,254) do echo %%x >> list.txt |  qwinsta /server:192.168.0.%%x >> list.txt

Go get a coffee and some snacks, or move on to your next job, because this is going to take a while.

No comments:

Post a Comment