If you live in the unfortunate world of IIS6, or perhaps you’re just masochistic, you’re going to use ADSI in PowerShell to work with IIS. A friend of mine showed me a handy way to delete log files older than a certain date using an ADSI query in PowerShell.
# Get the directory where the IIS logs are stored
$Location = [adsi]"IIS://localhost/w3svc" | select LogFileDirectory | %{$_.LogFileDirectory}
# query all .log files older than 14 days. Then delete all of those files.
Dir "$Location\w3svc**.log" | ?{$_.LastWriteTime -lt
(Get-Date).AddDays(-14)} | del