Author: Brian Reid, Brianreidc7 (Twitter);

Author: Brian Reid, Brianreidc7 (Twitter);

<p>##### # # Name: Remove-ExchangeLogFiles.ps1 # Author: Brian Reid, @BrianReidC7 (Twitter); http://www.c7solutions.com/ # Reference: http://www.c7solutions.com/2013/04/removing-old-exchange-2013-log-files-html # # This script will get all Exchange 2013 servers in the organization and then delete the logs (older than 30 days) across all the # servers for you from one machine. You run this second script from Exchange Management Shell (run as administrator) and need remote # file access to C$ (or whichever folder you set in the script) to all the servers Exchange 2013 servers. # #####</p><p>Set-Executionpolicy RemoteSigned</p><p>$Days = 30 ### You can change the number of days here ### $ExchangeInstallRoot = "C" $IISLogPath = "Inetpub\logs\LogFiles\" $ExchangeLoggingPath = "Program Files\Microsoft\Exchange Server\V15\Logging\"</p><p>Write-Host "Removing IIS and Exchange logs; keeping last" $Days "days"</p><p>Function CleanLogfiles($TargetFolder) { $TargetServerFolder = "\\$E15Server\$ExchangeInstallRoot$\$TargetFolder"</p><p>Write-Host $TargetServerFolder</p><p> if (Test-Path $TargetServerFolder) { $Now = Get-Date $LastWrite = $Now.AddDays(-$Days) $Files = Get-ChildItem $TargetServerFolder -Include *.log -Recurse | Where {$_.LastWriteTime -le "$LastWrite"}</p><p> foreach ($File in $Files) { #Write-Host "Deleting file $File" -ForegroundColor "Red" ### Remove comment mark (#) from the front of this line to see files being deleted during script run ### Remove-Item $File -ErrorAction SilentlyContinue | out-null} }</p><p> else { Write-Host "The folder $TargetServerFolder doesn't exist! Check the folder path!" -ForegroundColor "red" } }</p><p>$EX2013 = Get-ExchangeServer | Where {$_.IsE15OrLater -eq $true} foreach ($E15Server In $EX2013) { CleanLogfiles($IISLogPath) CleanLogfiles($ExchangeLoggingPath) }</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us