Exchange 2016 rydde op i IIS og Exchange Logs
Exchange og IIS generere mange log-filer, som ligger forskellige steder og fylder.
Man kan køre dette Powershell Script (Run as Administrator) som rydder op i:
- 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
Gem som: ClearLogs.ps1
indhold:
Set-Executionpolicy RemoteSigned
$days=0
$IISLogPath="C:\inetpub\logs\LogFiles\"
$ExchangeLoggingPath="C:\Program Files\Microsoft\Exchange Server\V15\Logging\"
$ETLLoggingPath="C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces\"
$ETLLoggingPath2="C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs"
Function CleanLogfiles($TargetFolder)
{
if (Test-Path $TargetFolder) {
$Now = Get-Date
$LastWrite = $Now.AddDays(-$days)
$Files = Get-ChildItem $TargetFolder -Include *.log,*.blg, *.etl, *.txt -Recurse | Where {$_.LastWriteTime -le "$LastWrite"}
foreach ($File in $Files)
{Write-Host "Deleting file $File" -ForegroundColor "white"; Remove-Item $File -ErrorAction SilentlyContinue | out-null}
}
Else {
Write-Host "The folder $TargetFolder doesn't exist! Check the folder path!" -ForegroundColor "white"
}
}
CleanLogfiles($IISLogPath)
CleanLogfiles($ExchangeLoggingPath)
CleanLogfiles($ETLLoggingPath)
CleanLogfiles($ETLLoggingPath2)
I scriptet kan man definere hvor mange dage der skal gemmes:
f.eks. $days=0 kan sættes til 1 for gemme 1 dag tilbage.