Rem: Using WMI to Change HTTP Compression Settings

Here’s a script that automatically enables HTTP compression in IIS 6.0.

Ethan Wilansky

November 14, 2004

3 Min Read
ITPro Today logo in a gray background | ITPro Today


Can I use Windows Management Instrumentation (WMI) to access the Microsoft IIS 6.0 metabase? Specifically, I want to enable HTTP compression settings in IIS 6.0. I know I can use Active Directory Service Interfaces (ADSI), but I would like to better understand how I can perform that task with WMI.

You're in luck. IIS 6.0 includes an IIS WMI provider, so you can use WMI to configure the IIS metabase. Earlier IIS versions, such as IIS 5.1 in Windows XP, don't contain the IIS WMI provider. Therefore, for earlier IIS platforms, you must write scripts that use the ADSI IIS provider.

HTTP compression is a hot topic because Microsoft has improved HTTP compression in IIS 6.0. From a practical standpoint, HTTP compression improves the speed at which pages are loaded on compression-enabled clients browsing the site. There are also potential cost savings if you pay for server bandwidth usage. However, to enable HTTP compression in IIS 6.0, you have to make several changes to the IIS metabase. Some of these changes are configurable from the IIS Manager console, but most require you to edit the IIS metabase with a script or third-party tool.

I wrote ModifyHTTPCompression.vbs to automatically make many of the crucial HTTP compression changes for you. The script is too long to print here, but you can download it from the Windows Scripting Solutions Web site. Go to http://www.windowsitpro.com/windowsscripting, enter 44335 in the InstantDoc ID text box, then click the 44335.zip hotlink.

Before you run ModifyHTTPCompression.vbs, you should follow several important steps:

  1. Read the DotNetJunkies article "Enabling HTTP Compression in IIS 6.0" (http://www.dotnetjunkies.com/howto/16267d49-4c6e-4063-ab12-853761d31e66.dcik) to completely understand the HTTP compression changes that the script makes for you. This article shows you how to manually enable the key HTTP compression settings.

  2. Review ModifyHTTPCompression.vbs carefully and read the comments. Some of the comments explain optional adjustments you can make to the script's settings.

  3. Change the strComputer variable value to the name of the computer on which you intend to enable HTTP compression. You can use a NetBIOS name, IP address, or Fully Qualified Domain Name (FQDN). The target computer must be running Windows Server 2003 and IIS 6.0.

  4. Test the script on a development server before you enable compression on any production servers. If it works fine on that server, thoroughly test the compression changes on one production server before you run the script in a Web farm.

  5. Use an administrative user account to run the script on the target computers.

Note that the script takes the precaution of backing up IIS 6.0's metabase before modifying it. However, if you want a separate backup, you can use the IIS Manager console or IIS 6.0's iisback.vbs utility. Also note that making the HTTP compression modifications slightly affects a production server's uptime because the script stops and restarts IIS 6.0 after the modifications are made. Because all systems differ, you should make sure that the HTTP compression modifications won't significantly affect your production servers' uptime. If it does, be sure to run the script during scheduled downtime or during periods of reduced usage.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like