See correction to this article

Most Microsoft IIS administrators face numerous repetitive tasks: Creating sites, creating virtual directories, searching for a particular setting, determining security compliance—to name just a few. Using GUIs to complete these tasks over and over is tedious and time-consuming. Scripting such tasks is a faster and more powerful method, and IIS provides many easy-to-learn scripting interfaces. By customizing the scripts that accompany this article, you can retrieve, create, and modify IIS configuration data. The sample scripts use Active Directory Service Interfaces (ADSI) and JScript and work on IIS 4.0 and later. Of course, you must run all these administrative scripts under the security context of a user who has administrative rights on the target machine.

Your First Script
Your first task in learning IIS administrative scripting is to configure your server so that your scripts' results will be output as text in the command-shell window rather than as graphical message boxes. To do so, open a command shell on the IIS server and type

cscript //H:cscript

To test this configuration, let's create a simple JScript script that returns the path to your default Web site. Open Notepad or another text editor and enter the following code on one line:

WScript.Echo ("Physical path of my
default web-site: " + GetObject
("IIS://localhost/W3SVC/1/ROOT").Path);

Save the file as iispath.js. Go back to the command shell and type

iispath.js

This command runs the script. If you configured the server properly, you'll see output similar to the output that Figure 1, page 56, shows. This output shows the physical path of your default IIS Web site. Congratulations—you've written your first IIS script. Now, let's move on to bigger and better things.

   Prev. page   [1] 2 3 4 5     next page
CORRECTIONS TO THIS ARTICLE:
In Brett Hill and Thomas Deml's "Scripting IIS Administration" (December 2003, http://www.win netmag.com, InstantDoc ID 40713), a figure was identified incorrectly. In the print article, Figure 4 should be listed as Figure 3. We apologize for any inconvenience these errors might have caused.




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

This example is in error "notepad %windir%\system32\inetsrvmetabase.xml" there is a missing "\" between "..\inetsrv" and "metabase.xml"

Roy E Jensen

In the middle of page 4, in

"...To find a site ID for an IIS 5.1 site, run the findweb.vbs script, which resides by default in the %windir%\Inetpub\Adminscripts folder...",

the script actually resides by default in c:\Inetpub\Adminscripts folder.

Hongliang Qiang

Found these articles very intuitive, thanks very much.

Anonymous User

Article Rating 5 out of 5