If you notice that your Exchange Server does not accept new mails or delivers them with a delay to user mailboxes, you can verify the symptoms regarding back pressure insufficient system resources in this post :
Verify Back Pressure Exchange 2013 / 2016
After you have determined Back Pressure as the root cause and it is disk space-related ( Event ID 15006 ) it is time to wipe parts of the logs and traces which are eating up your disk space.
Especially if you have more servers in your environment the script below can help you in a very convenient way.
It cleans the logs under the defined folder-paths. If a folder is not found the script shows an error. No worries, what does not exist can not be filled and cleaned.
All defined existing folders will be cleaned out. Feel free to adjust the folder paths for your needs or just comment out non-existing lines with paths to non-existing folders.
# Back Pressure Insufficient System Resources Clean Up Script
# Published on WebBanshee.net
# Written by : init.B
#———————————————————————————————————–
Add-PSSnapin *exchange* -ErrorAction SilentlyContinue
# datetime parameter to measure the CERES logs LastWriteTime against
$dateCERES = (Get-Date).AddHours(-4)
# datetime parameter to measure the DailyPerformanceLogs LastWriteTime against
$dateDPL = (Get-Date).AddDays(-1)
# datetime paramete for inetpub logs
$dateinetpub = (Get-Date).AddDays(-4)
# datetime parameter for all other logs
$dateother = (Get-Date).AddHours(-8)
# all mailboxservers or specified mailboxservers
$mbservers = Get-MailboxServer | Sort-Object name
#$mbservers = “Server01″,”Server02″ ,”Server03”
Write-Host “Deleting the specified logs on the following servers…”
FOREACH ($mbserver in $mbservers)
{
# tracker for human eyes
$mbserver.Name
# get and delete both types of CERES logs
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces” | Where-Object {$_.lastwritetime -lt $dateCERES -and $_.Extension -eq “.etl”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs” | Where-Object {$_.lastwritetime -lt $dateCERES -and $_.Extension -eq “.log”} | Remove-Item
# get and delete DailyPerformanceLogs
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\DailyPerformanceLogs” | Where-Object {$_.lastwritetime -lt $dateDPL -and $_.Extension -eq “.blg”} | Remove-Item
# get and delete ews and httpproxy logs, except for powershell
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Autodiscover” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Eas” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Ecp” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Ews” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Mapi” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Oab” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\Owa” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\OwaCalendar” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\HttpProxy\RpcHttp” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\Ews” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
# get and delete activemonitoringtracelogs
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\Monitoring\MSExchangeHMWorker\ActiveMonitoringTraceLogs” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
# get and delete probecache & respondercache logs
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\PersistentState\ProbeCache” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
Get-ChildItem -Path “\\$mbserver\C$\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\PersistentState\ResponderCache” | Where-Object {$_.lastwritetime -lt $dateother -and $_.Extension -eq “.log”} | Remove-Item
# get and delete inetpub logfiles
Get-ChildItem -Path “\\$mbserver\C$\inetpub\logs\LogFiles\W3SVC1” | Where-Object {$_.lastwritetime -lt $dateinetpub -and ($_.Extension -eq “.log” -or $_.Extension -eq “.zip”)} | Remove-Item
}
To prevent back pressure insufficient system resources you can set this script as a scheduled task to have the logs cleaned up on a regular basis.
If you haven’t done it already you can move the mail.que file to a location on another drive to free up even more disk space.
Change location of mail.que file Exchange 2013 / 2016