<# Export eventlog for a mailbox. Parameters are username (mandatory) and enddate default today. Exhange keep eventlogs for 7 days by default. #> [CmdletBinding()] Param ( [Parameter(Mandatory=$true, ValueFromPipeline = $false)] [Alias('User')] [string]$UserName, [Parameter(Mandatory=$False)] [string]$EndDate = (Get-Date) ) $db = (get-mailbox $UserName).database $mb=(get-mailbox $UserName).exchangeguid Get-DatabaseEvent $db -MailboxGuid $mb -resultsize unlimited | ? {$_.documentid -ne 0 -and $_.CreateTime -ge $EndDate} | export-csv c:\temp\EventHistory$username.csv -NoTypeInformation -Encoding UTF8