
It’s a great script to cleanup logs on Exchange 2013/2016/2019 and get free space.
#THOSE WHO REMAIN SCRIPT 2019 HOW TO#
In this article, you learned how to clear Exchange logs with PowerShell. Note: Do you like to automate the script? Read more on how to Cleanup Exchange logs automatically with scheduled task. Did the cleanup logs Exchange script help you out? The script did cleanup 14GB of the Exchange logs. Have a look again at how much free space you have on the drive. Wait till the PowerShell window disappears from the screen. A PowerShell window will show up and the script is cleaning up the logs. Right-click the file CleanupLogs.ps1 and click on Run with PowerShell. C:\inetpub\logs\LogFiles\Ĭ:\Program Files\Microsoft\Exchange Server\V15\Logging\Ĭ:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces\Ĭ:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs\ Run the cleanup logs Exchange script Before running the cleanup logs scriptīefore you run the script, have a look at how much free space you have on the drive. Create a scheduled task to clear Exchange logs that will run every day with the service user account. Give the service user account read/write permission on the below four folders. I recommend making a service account in Active Directory. If the script does not have permission, it will not cleanup logs in that folder. Give your account permission access to the below four folders. Save the file on the Exchange Server in the following path C:\scripts\. If you have changed the path of the Exchange configuration, change the path in the line 11,12,13, and 14. That means it will cleanup logs from the Exchange Servers that are older than 2 days. Write-Host "The folder $TargetFolder doesn't exist! Check the folder path!" -ForegroundColor "red" Remove-Item $FullFileName -ErrorAction Silentl圜ontinue | out-null

Write-Host "Deleting file $FullFileName" -ForegroundColor "yellow" If ($ExecutionPolicy -ne "RemoteSigned") | Select-Object FullName If it does not give you a prompt to save the file, right-click on CleanupLogs.ps1 and click save link as. You can also download the CleanupLogs.ps1 script (direct link).

#THOSE WHO REMAIN SCRIPT 2019 CODE#
Prepare the cleanup logs Exchange scriptĬopy the following code and paste it in Notepad.
