something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


# Exchange Server Admin Audit Report
# This script has been written to report on events in the Exchange server admin audit log over the last 48 hours.
# This has been written for Exchange 2010 SP3 and to be compatible with PowerShell 2.0
# Version 1.0 -  James Pearman, November 2018


$Date = Get-Date
$yesterday = (Get-Date).AddHours(-48)
$EmailTo = "[email protected]"
$EmailFrom = "[email protected]"
$EmailSubject = "Exchange Server Audit Report" + $Date
$SMTPServer = "smtp.domain.com"
$ReportFileName = "C:\Support\ExchAdminLog.html"

#Create HTML Table

$Style = "<style>"
$Style = $Style + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$Style = $Style + "TH{border-width: 1px;padding: 4px;border-style: solid;border-color: black;background-color: #BDBDBD}"
$Style = $Style + "TD{border-width: 1px;padding: 4px;border-style: solid;border-color: black;}"
$Style = $Style + "</style>"
$Pre = "Exchange Server Admin Log"

#Get Admin Logs

$logs = Search-AdminAuditLog -StartDate $yesterday | Select-Object ObjectModified, CmdletName, @{Expression = { $_.CmdletParameters }; Label = "CmdletParameters"; }, @{Expression = { $_.ModifiedProperties }; Label = "ModifiedProperties"; }, Caller, Succeeded, Error, RunDate

$Logs | ConvertTo-HTML -Head $Style -PreContent $Pre > "$ReportFileName"

#Send Email

$Body = [System.IO.File]::ReadAllText('C:\Support\ExchAdminLog.html')
Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $Body -BodyAsHtml -SmtpServer $SMTPServer

Back to Top


Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.


Back to Top