I have been learning to use Powershell over the past few months. Every script I write, I write in Powershell so I can improve my skills. It has become aparent to me that the name is very appropriate. With very simple commands that even a (gasp) non-programmer can do, you can automate just about anything. Today, I automated a way to create users in Active Directory. The script (if I can call it that since it could all be done from one line) pulls in a CSV file that has been prepopulated with users, assigns the fields to AD attributes, and creates the users. It can put them in different OUs, assign an expiration date, and much more.
I did not tackle every user property, just what I thought was important for our organization. I'll probably even add a couple fields for us. The point, however, is that this is a more robust and fully-functional example of how to add multiple users to the domain easily. From here you could set up a script to pull information from your HR system and either dump it into the CSV file for processing or have it run the import directly.
Here is a link to the script.
Showing posts with label Tool. Show all posts
Showing posts with label Tool. Show all posts
Monday, April 28, 2008
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.
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.
Subscribe to:
Posts (Atom)