Skip to content

SammyKrosoft/Clean-Exchange-Log-Files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 

Repository files navigation

Clean-Exchange-Log-Files

NOTE: there is an issue when I publish releases of the script - for now I'll just provide the link to the RAW text script, or you can just download the whole repository and just keep the CleanExchangeLogFiles.ps1 file. Apologizes for the invonvenience

  • PowerShell script taken and adapted from Edward Van Biljon (was on his Technet Gallery, which has been decommissioned in 2020 (original link: gallery.technet.microsoft.com/office/Clear-Exchange-2013-Log-71abba44) with the following modifications:

  • No need to modify the IIS and Exchange Path => the script uses environment variables to find the Exchange Logging and IIS Logging paths (script has to be used on Exchange servers to remove the log files)

  • added -DoNotDelete switch to just assess the amount of files that we'd potentially remove

  • added -NoConfirmation switch to avoir being prompted to continue or cancel

  • added progress bars

  • added script log file

  • Usage

    • example to view folder sizes only for IIS log files aged 2 days and older:
.\CleanExchangeLogFiles.ps1 -Days 2 -DoNotDelete

sample output: image

  • example to clean Exchange Logging files and IIS Log files aged 5 days and older:
.\CleanExchangeLogFiles.ps1 -Days 2

You'll see the progress bars (one for the folder it's cleaning, and one for the files it's cleaning for each folder): image

Usage on a Windows Scheduled task

NOTE: to use in a Windows Scheduled task, use the -NoConfirmation switch to bypass the Confirm Yes/No dialog box. Otherwise the script will just wait for a user input, which will never come because it's a Windows Scheduled task, most likely configured as "non interactive" because we want it to be automatic.

In that case, use the -NoConfirmation switch:

.\CleanExchangeLogFiles -Days 2 -NoConfirmation

This will launch the script in files deletion mode immediately, without the need of a user interaction.

Log file

The script log file will be located on the user's Documents folder: image

And it will contain the same information as on the screen: image

Download the Latest version of the script

Either download the whole repo, or copy/paste the text of CleanExchangeLogFiles.ps1 from this link

About

PowerShell script to purge Exchange Log files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published