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.
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:
Then you can iterate through each to document the current values, for example, for website n:
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):
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.