Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there away in IIS 6 to programmaticly turn on/off logging in a web farm. we have 10 servers and I don't want to when needed log on to each and flip logging on, and then when we are done login and turn it off.

I know about remote management tools..but would like to use a powershell script or the like.

share|improve this question
up vote 5 down vote accepted

The easiest way to do this programmatically (using ADSI and VBScript) would be to use adsutil.vbs (installed by default in the C:\InetPub\AdminScripts folder) to modify the relevant configuration options in the metabase. You can find more about the IIS 6 version of the script here...

Because logging can be set at a number of levels, I'd suggest using the following to find all the locations of the LogType property:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs FIND LogType

Then you can iterate through each to document the current values, for example, for website n:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs GET /LM/W3SVC/n/LogType

And finally—what you're looking for—here's an example to disable logging on website n by setting the value to zero (you'll want to iterate through all of the nodes found, because child node settings always override inherited parent settings):

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET /LM/W3SVC/n/LogType 0

All of the above commands can also be appended with -s:SERVERNAME to perform the command against a server other than localhost.

There are a number of alternative methods of modifying the metabase, including (but not limited to) using ADSI through another language, WMI, or direct XML manipulation. Please also note that that these instructions are valid for IIS versions 4, 5, 5.1 and 6. Version 7 is slightly different, but with the optional IIS 6 compatibility components installed, these instructions would be valid on IIS 7.0 and 7.5 as well.

share|improve this answer
Thank you, this is exactly what I needed! – Thomas Denton Aug 21 '09 at 15:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.