1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# Mailbox $Mailbox = "Mail@domain.com" # Exchange server contains tracking logs - by default CAS $Serv = "exch01.domain.com" $Now = Get-Date $DayBack = (7,6,5,4,3,2,1) Write-Host $Mailbox" report" Write-Host "====================" foreach ($DayIndex in $DayBack) { $CT = $Now.AddDays(-$DayIndex) $CTDayOfWeek = (Get-Date($CT)).DayOfWeek $CTToDisplay = Get-Date($CT) -Format dd.MM.yyyy $CT = Get-Date($CT) -Format MM/dd/yyyy $CTStart = $CT+" 0:00:00AM" $CTEnd = $CT+" 23:59:59PM" $MailCount = (Get-MessageTrackingLog -Recipients $Mailbox -server $Serv -start $CTStart -end $CTEnd -ResultSize 99999 | Where-Object {$_.Source -ilike "*STORE*" -and $_.EventID -ilike "*DELIVER*" -and $_.Sender -inotlike "*MicrosoftExchange*"} | Select-Object -Unique InternalMessageId).count Write-Host $CTDayOfWeek $CTToDisplay": "$MailCount } |