Thursday, January 2, 2014

Purge SQL Server Reporting Services logs

SQL Server 2008 has a bug which is not cleaning the logs automatically for reporting service, delete logs (older than 14 days) safely with below power shell commands and it can be scheduled through task manager.

cd "C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\LogFiles"

Get-ChildItem -Recurse | Where-Object {($_.LastWriteTime.Date -le (Get-Date).Date.AddDays(-14) -and ($ -like "*.log"))} | Remove-Item