Condividi tramite


Aide-mémoire – memory-helper – How to delete IIS logs using Powershell (IIS logging can take GBs of disk space, watch out !)

 

Hi all,

 

A quick “tip” that can be useful as IIS logging usually generates GB of files that we don’t necessary monitor, and I thought it was important enough to write a quick post about it, as I got lately several examples of customers for which C: free drive space fell below 10%;

You may ask yourself, why this guy is writing such a post on an Exchange Server blog ? What does this has to do with Exchange ?

- reason is Exchange is using the C:TEMP or C:WindowsTemp folder for a few things like message content conversion (the HUB role in particular). So if we run out of disk space on C:, there is a risk that the Transport Service stops; or even worse, the Windows host can stop working because there is no more space to handle temp files for other OS related tasks.

 

So continue to monitor your disk space on the C: drive, and you can use the below command line to check and purge your IIS Logging directory (if you need IIS logging to stay activated) :

get-childitem -Path C:inetpublogsLogFiles -recurse | where {$_.lastwritetime -lt (get-date).addDays(-90)} | Foreach-Object {del $_.FullName}

 

Also useful if it appears you don’t need IIS logging because there is no troubleshooting need, you can simply deactivate IIS logging:

 

Enable or Disable Logging (IIS 7)

https://technet.microsoft.com/en-us/library/cc754631(v=WS.10).aspx

 

Cheers,

Sam.