Subscribe to Windows IT Pro
November 25, 2003 12:00 AM

Scripting IIS Administration

Automate time-consuming tasks
Windows IT Pro
InstantDoc ID #40713
Rating: (1)

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.

Related Content:

ARTICLE TOOLS

Comments
  • Anonymous User
    7 years ago
    Apr 14, 2005

    Found these articles very intuitive, thanks very much.

  • Hongliang Qiang
    8 years ago
    Feb 26, 2004

    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.

  • Roy E Jensen
    9 years ago
    Dec 31, 2003

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

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

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