Administering IIS typically involves reading and configuring settings and performing various tasks such as backing up IIS. In "How to Use a Script to Access and Read the Metabase," October 2002, InstantDoc ID 26261, I described how to use Microsoft Active Directory Service Interfaces (ADSI) scripts to perform an important IIS administrative taskreading the metabase. In this article, I explore another important IIS administrative task: writing settings to the metabase. With simple script examples and straightforward, applied discussion, I demonstrate how to use ADSI scripts to configure IIS. If you're unfamiliar with the IIS metabase, ADSI scripting, or IIS Admin Objects, be sure to read "How to Use a Script to Access and Read the Metabase."
ADSI scripts can improve IIS administrative operations in several ways. Scripts let you
- duplicate IIS configuration settings from one server to another. After you create a configuration script for one server, you can easily run the script against newly installed servers so that each Web server on the network is similarly configured.
- maintain consistent IIS configurations across the enterprise. You can run a script on multiple IIS servers to configure various metabase settings.
- apply IIS configuration settings efficiently. Using scripts to configure IIS settings is typically faster than using the IIS console to configure settings.
- configure settings that might not be available from the IIS console.
Before you attempt to use scripts to configure the metabase, be sure to back up the metabase because an improper metabase configuration can cause IIS operations to fail. In an upcoming article, I'll explain how to use a script to back up the metabase, but in the meantime, you can perform the backup from the IIS console. Another important consideration when using scripts to configure the metabase is that you can't use ADSI scripts to perform any administrative task that you can't complete using other means. ADSI uses user credentials to connect to the metabase; all the script examples in this article use a function that connects to the metabase in the context of the currently logged-on user.
Configure Keys in the Metabase
IIS stores configuration settings in metabase keys. Before you attempt to configure a metabase key's attributes, you need to consider the attribute's data type because you don't configure all attributes in the same way. For example, configuring the HTTPErrors setting, a List data type attribute that can have many values, requires a different script procedure than configuring the ServerAutoStart setting, a Boolean data type attribute that has just one valueTrue or False. Web Table 1 (http://www.windowswebsolutions.com, InstantDoc ID 26932) shows the data types found on a Windows XPbased computer running IIS 5.1. (These data types apply to Windows 2000 also.) Note that the Integer data type in Web Table 1 includes both 32-bit and 64-bit data types.
The table's Totals column, and thus the distribution of metabase keys, varies depending on the IIS version and the metabase key to which the script binds. However, within the IIS metabase hierarchy, the Boolean, Integer, and String data types occur most frequently. By running the script IISAtt_ReadDataTypes.vbs, which Web Listing 1 shows, you can determine the distribution of data types for your IIS implementation. Also, "How to Use a Script to Access and Read the Metabase" contains a script that lists each metabase key's attributes along with its data type and value (if any).
You use similar methods to configure all Boolean, Integer, and String data types. See the Web sidebar "Configure Boolean, Integer, and String Data Types" (http://www.windowswebsolutions.com, InstantDoc ID 26985) for a description of a script that demonstrates this configuration.
Configure List Data Types>
Boolean, Integer, and String data types represent approximately 80 percent of IIS data types. The next most common data type is List. The List data type contains zero or more items and can be multivalued (i.e., can store more than one value). Common List data type attributes on a computer running IIS 5.1 include
- ServerBindings
- SecureBindings
- HttpPics
- HttpCustomHeaders
- HttpErrors
- ScriptMaps