$logs = Get-ChildItem -Path C:\inetpub\logs -Recurse -Filter *.log $oldest = (get-date).AddDays(-30) foreach($log in $logs){ if($log.LastWriteTime -lt $oldest){ $log.Delete() } }
Use this script to cleanup all sccm primary site IIS logs which takes lots of space and each files are huge in size.