Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The preceding sections described how to create an OU, a user account, and a group, and set the description attribute on each of these objects. The next common task is to read an attribute of each object.
Reading an Active Directory object s attributes involves two simple steps:
The goal of the three scripts in this section will be to read the description attribute of the HR OU, the MyerKen user account, and the Atl-Users group and display their values on the screen.
Important
The script in Listing 5.8 reads and displays the description attribute of the OU named HR in the na.fabrikam.com domain. To carry out this task, the script performs the following steps:
Listing 5.8 Reading the description Attribute of an OU
|
|
When this script runs in the na.fabrikam.com domain, it echoes the description of the HR OU to the command window, as shown:
Human Resources
The script in Listing 5.9 reads and displays the description attribute of the user account named MyerKen, located in the HR OU of the na.fabrikam.com domain.
Listing 5.9 Reading the description Attribute of a User Account
|
|
When this script runs in the na.fabrikam.com domain, it echoes the description of the user account to the command window, as shown:
HR employee
The script in Listing 5.10 reads and displays the description attribute of a global group named Atl-Users, located in the HR OU of the na.fabrikam.com domain.
Listing 5.10 Reading the description Attribute of a Group
|
|
When this script runs in the na.fabrikam.com domain, it echoes the description of the group to the command window, as shown:
Atlanta users
Important observations about the scripts in this section:
As demonstrated in this section, the process for reading attributes is uniform from one object to the next. In fact, within a particular task, the steps you follow from one object to the next are consistent. This consistency empowers you to write scripts that can read thousands of attributes from the many objects stored in Active Directory.
Send us your feedback | « Previous | Next » |