Instead of typing this in a command prompt one at a time:
wmic /node:ipaddress /user:administrator /password:mypassword bios get serialnumber
How can I run that against one entire subnet and output to a text document? Since I do this every couple months to verify our inventory of computers, I would assume there would be a much of easier way I could put this in a batch script instead of doing it manually.
2 Answers
You may put a list after node: node:ip1,ip2,ip3, or use a file node:@file - so just put all your ip addresses into a file and then run:
wmic /node:@nodes.txt /user:administrator /password:mypassword /output:out.csv bios get serialnumber /format:csvThat assumes user/password is the same on all machines.
4A for loop with a file redirection will work, although you might want to let it sit and run for a while if you have more holes in your node set (in otherwords, can't resolve the IP in the loop)
(FOR /L %s IN (1,1,254) DO wmic /node:192.96.1.%s /user:administrator /password:pass bios get serialnumber) >> c:\results.txt
If you plan to put this in a batch file, replace the %s with %%s. That is all.