I’ve got the question from a collegue to create a script to automatically change the IIS log directory for all websites in IIS. I’ve created this blog for reference purposes. This is a simple and small script but does the job for you. Run the following commands in PowerShell as administrator on the server which hosts IIS (you will need to run this on all servers in a SharePoint farm).

import-module webadministration
$logPath = Read-Host “Enter the log location (eg. D:\IISLogs). This directory will <strong>not</strong> be created if it doesn’t exist”
get-website | foreach {Set-ItemProperty "IIS:\Sites\$($_.name)" -name logFile.directory  -value $logPath}

Please leave a comment if you have any questions/remarks.


Leave a Reply

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.