Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

March 28, 2007 12:00 AM

An MMC-less Way to Add Computers to Global Groups

Windows IT Pro
InstantDoc ID #95164
Rating: (0)
Downloads
95164.zip

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 http://msdn2.microsoft.com/en-gb/library/aa772208.aspx. )

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 95164.zip file, which you can download by clicking the "Download the Code Here" link. I wrote this script for use on Windows XP.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.