kisslo

undelivered_emails_exchange2013.ps1

Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Exchange 2013
  2.  
  3. $ErrorActionPreference= 'silentlycontinue'
  4. $empty="{}"
  5. $internal="[a-z0-9!#\$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#\$%&'*+/=?^_`{|}~-]+)*@yourdomain\.tld$"
  6. Get-MessageTrackingLog -MessageSubject "Undeliverable" | Sort-Object -Property Recipients -Unique | foreach ($_.Recipients){
  7. if(($_.Recipients -ne $empty) -and ($_.Recipients -match $internal)){
  8. echo $_.Recipients
  9. Get-Messagetrackinglog -sender:$_.Recipients -EventID "FAIL" | ft Timestamp, Recipients
  10.                                                        }
  11. }
Add Comment
Please, Sign In to add comment