Log cleaning
Start Task Scheduler.
Click the Task Scheduler Library and click New folder… Name the
folder Exchange and click OK.
Click the created Exchange folder. Click Create Task…
We have three tabs that we are going to fill in. The tabs
are General, Triggers, and Actions.
We start with the first tab General.
Give the task name CleanupLogs. Change user account to SYSTEM.
Enable Run with highest privileges. Select Configure for Windows
Server 2016 if you have a Windows Server 2016. If you have another
Windows Server version running, select that.
Click the tab Triggers. Click New…
Select the settings Daily. Configure which time the script needs to start
running. For example 22:00:00. Make sure that it’s Enabled and click OK.
Click the tab Actions. Click New…
Make sure to copy and paste below to both of the fields.
Program/script: Powershell.exe
Add arguments (optional): -ExecutionPolicy Bypass C:\Scripts\
CleanupLogs.ps1
Click OK.
Click OK.
The clear Exchange logs task is scheduled. From now on, the task scheduler
will automatically delete Exchange logs. In the next step, you will run the
script to test if all is working great.
Run the cleanup Exchange logs task in
task scheduler
Click the created task CleanupLogs and Click Run. The Last Run
Result will show that The operation completed successfully. (0x0).
Make sure to check if the CleanupLogs task did clear the logs in the following
folders.
C:\inetpub\logs\LogFiles\
C:\Program Files\Microsoft\Exchange Server\V15\Logging\
C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces\
C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs\