I wrote a PowerShell script! :D It's super exciting - it makes a list of all the IPs in an IPv4 subnet and writes them to a text file! :D (I'm sure this accomplishment would not impress anyone with any non-zero amount of expertise in scripting, but this is my first time writing a script, gotta start with the small stuff.) The script can easily be
(
Read more... )
- ping each IP address in a series
- for each IP, if ping response is positive, use a WMI query, nslookup, and/or nbtstat -A to try to get the machine name, MAC address, and in the WMI case the OEM and model# of the machine
- if the previous step succeeded in getting the machine name, use WMI to try to get a list of users who are in the local administrator group on the system, and query Active Directory to find out who created the machine account (assuming the system is domain-joined)
- if the script has been run before and a previously generated list exists, check the MAC address against the list to see whether it's a new entry or not
- write all that info to a datestamped file in a format something like this: new (*Y*|n), ping response (y|n), machine name, OEM and model #, MAC address, members of local admin group, AD machine account? (y|n), creator of machine account
So recording ping response is one of the subcomponents that I'll have to figure out. :) I also want to see if I can pipe all that data into an Excel spreadsheet so it'll be easier to work with, might have to settle for a CSV though.
The purpose of this script would be to get info about machines on our lab subnet - a lot of times people add a new machine to our big shared lab without recording the machine name and rack position, plus we don't have a good way yet of recording other info. Of course the script won't tell us the physical location of a machine in the lab, but that should be much easier to figure out once we know the machine name, admin group members, and who set it up (machine account creator).
At least I have appending data to the end of a file figured out, out-file -append does that...:)
Reply
Leave a comment