Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Large organizations typically have more than one system administrator. In addition, those administrators generally are not responsible for managing the entire network; instead, they most likely have been delegated control over some subset of the network. For example, Administrator A might be responsible for managing users and computers in the Finance department, while Administrator B might be responsible for managing users and computers in the Human Resources department.
To facilitate system administration, Active Directory is often designed to mimic these management areas. Instead of placing all computer accounts in the Computers container, computer accounts might be put in organizational units (OUs) that correspond to these management areas. Thus all the accounts for computers belonging to the Finance department would be placed in the Finance OU, and all the accounts for computers belonging to the Human Resources department would be placed in the Human Resources OU.
Structuring Active Directory in this fashion not only facilitates system administration but also of benefits script writers. For example, suppose you need to write a script that takes a hardware inventory or checks the service pack version for all the computers under your control. If those computer accounts and only those computer accounts are stored in the same Active Directory container, you do not have to create a text file or database from which to extract computer names. Instead, you can simply bind to the appropriate Active Directory container and retrieve all the computer names from there.
Binding to Active Directory also ensures that you will have the most up-to-date list of computers, without having to do additional work to maintain a text file or database containing computer names.
To retrieve a list of computer names from Active Directory, use Active Directory Service Interfaces (ADSI) and:
atl-dc-01 atl-dc-02 atl-dc-03 atl-dc-04
Listing 17.4 contains a script that retrieves arguments from an Active Directory container. To carry out this task, the script must perform the following steps:
The Dictionary object will be used to store server names as those names are read from Active Directory.
The counter variable will be used as the key to each element in the Dictionary. The name of the server will be used as the item associated with each key.
Because Computers is a container, you must use the syntax CN=Computers. If you were binding to an OU (for example, the Finance OU), you would use the syntax OU=Finance OU.
This prevents the script from attempting to run against user accounts or any other noncomputer objects that might be stored in this container.
This query returns a collection consisting of all the services installed on the computer.
Listing 17.4 Retrieving Arguments from an Active Directory Container
|
|
Send us your feedback | « Previous | Next » |