I wanted to get the current DNS servers set on all the servers in the domain.
1. I exported the list of servers currently in the domain to a file.
2. I downloaded SysInternals PSTools from Microsoft Technet website.
In these PSTools, we have PSExec command which helps run commands remotely from a computer.
I extracted the PSTools zip to my C: drive.
3. I created a folder for Logs on my PC c:ipconflogs
4. I then created a command file which runs for each server of my list :
“PSExec /accepteula \computer_name ipconfig /all >>c:ipconflogs computer_name.txt”
i. To create the command file, I usually edit an Excel file as you see below.
ii. Then I copy-paste to Notepad and delete all tabs following “” and preceeding “.txt”. After that I replace all tabs remaining by spaces. (This is document edition actually…)
5. Alright, now I run my command and I have a set of .txt files in the c:ipconflogs folder.
6. I run the following command to gather all the information in one csv file:
C:\ipconflogs>copy *.txt report.csv
7. I then open my csv file in Excel and find that the information is gathered into one column.
8. I then set a filter to only show lines where I have *name* (for the host name) and *172.* (for the IP addresses). Actually this is easy because all my IP addresses are in 172.x.y.z format. If you have many different subnets, I cannot guarantee the filtering will be easy.
9. I am done, I now have all my servers, their IP address(es) and the DNS servers set on them:
I can even filter more by copying this filtered information to another sheet.
I hope this is helpful to you.