Sunday, April 20, 2008

Network Computer Inventory Script - Rough Draft

OK, so who hasn't seen a script or program that takes an inventory of your local computer (Belarc Advisor is a good example) or an entire network of computers (Newt works well)? Well, I like both of these options, but I wanted more control (and less cost) over the inventory. I did a little searching for a solution that utilized Powershell. I came across a solution from Peter Stone. I took his script, ripped it apart, and put it back together a little differently. His solution was designed to output the information to a html file and to the screen for the local computer only. It utilized WMI, which was perfect for my purposes.

My goal was to create a script that scanned a list of computers from one central computer, get a full inventory of computer features, and store them in an easy to access format for later use. I ended up using a free snap-in from Quest for accessing my Active Directory to get a computer list (I didn't feel like doing a recursive ADSI query when the tool from Quest was so easy to use).

The way this script works is that the AD is scanned for a complete list of computers. Each computer is pinged to see if it is online. If it is, a complete WMI scan is done to gather all of the values desired. The entire scan is written to an XML file with the computer's name as the file name.

This script is in (very) rough draft format. It works, it does the job fairly well, and it doesn't have any major bugs. However, the code isn't clean, some attributes are missing (like CD-ROM information), and some things could be done better (capture a list of computers that were missed for the next scan, etc.). I also am starting to develop a wish list of other ideas that I could do with this script (optional scanning of categories, optionally add all of the computers to one XML file instead of one per computer, etc.).

I am posting this script now so you can see it and dream with me. I will post the final version sometime next month, hopefully. Here it is.

No comments: