Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.