Our organization uses Microsoft Systems Management Server (SMS) 2003 to deploy software and updates. To ensure that SMS packages are received by computers worldwide, we allow our IT administrators to add computers to the predefined SMS global groups. Using the Microsoft Management Console (MMC) Active Directory Users and Computer snap-in to add computers to global groups takes multiple searches and many mouse clicks, so I wrote the AddComputers.vbs script to help administrators save time. This script also provides flexibility in that the IT administrators can add only those computers to which they want to deploy SMS packages.

Assuming CScript is the default engine, the IT administrator uses the following syntax to launch the script

AddComputers.vbs                                 C:\pclist.txt global_group

where global_group is the name of the global group to which they want to add the computers that are listed in C:\pclist.txt. In this input file, each computer name is placed on a separate line. For example, the input file might look like

Pc001                              Pc002                              Pc003

Listing 1 shows the main block of code in AddComputers.vbs. As you can see, after making the necessary declarations and checking for the input file's existence, the script converts the group name provided on the command line into a distinguished name (DN). It accomplishes this conversion using the dn function that Listing 2 shows. The dn function uses NameTranslate object, which is an Active Directory Service Interfaces (ADSI) object that translates ADsPath entries from one format to another in the LDAP namespace. (For more information about this object, see the "ADSI Objects of LDAP" Web page at )

With the global group's DN in hand, AddComputers.vbs checks for the group's existence. Once confirmed, the script opens and reads the input file, storing the computer names in a Dictionary object. For each computer name in the Dictionary object, the script calls the Add function. This function then adds the computer to the global group.

You can find AddComputers.vbs in the file, which you can download by clicking the "Download the Code Here" link. I wrote this script for use on Windows XP.