Powershell – Disable IIS Logging

Powershell script to totally disable IIS logging on for all Sites

#Disable IIS Logging
$dontLog = (get-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog).Value
Write-Output " IIS Logging (dontLog) was set to $dontLog" 
set-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog -value $true
$dontLog = (get-WebConfigurationProperty -PSPath "IIS:\" -filter "system.webServer/httpLogging" -name dontLog).Value
Write-Output " IIS Logging (dontLog) was now to $dontLog"  

It is important to note that a number (if not all….) of the names (settings) in IIS are case sensitive. so:
-name dontLog
must be specified in the correct case
-name dontlog will not work, will not error and will not disable logging

 

 

 

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.