#get-forwardingrules # # Check all Inbox Rules from given mailboxes for automatic fowarding to # # 20181011 Initial Version # 20181030 Fix for Office 365 [cmdletbinding()] Param ( [parameter(ValueFromPipeline=$True)] $mailbox ) begin { write-host "Report-ForwardingRules: Start" [long]$count=0 } Process { $count++ Write-host -nonewline “Processing ($($count)) $($mailbox.PrimarySmtpAddress.tostring()) “ $inboxrules = get-inboxrule -mailbox $($mailbox.PrimarySmtpAddress.tostring()) $result = "" | select PrimarySmtpAddress,Rulename,Typ,Routingtype,destination $result.PrimarySmtpAddress = $mailbox.PrimarySmtpAddress If ($inboxrules) { Write-host -foregroundcolor green -nonewline “Total Rules: $($inboxrules.count) ” foreach ($inboxrule in $inboxrules) { $result.rulename = $inboxrule.name write-host "." -nonewline if ($inboxrule.forwardto -ne $null) { write-host "F" -nonewline -BackgroundColor Magenta -ForegroundColor black foreach ($recipient in $inboxrule.forwardto) { $result.Typ="forwardto" $result.Routingtype = $recipient.Routingtype $result.destination = $recipient.Address $result } } if ($inboxrule.redirectto -ne $null) { write-host "R" -nonewline -BackgroundColor Cyan -ForegroundColor Black foreach ($recipient in $inboxrule.redirectto) { $result.Typ="redirectto" $result.Routingtype = $recipient.Routingtype $result.destination = $recipient.Address $result } } } write-host " Done" } Else { Write-host “No Rules Found” } } End { write-host "Report-ForwardingRules: End" }