Get-Mailbox -OrganizationalUnit "OU=orgunitname,dc=subdomain,dc=topdomain" -ResultSize 8000 -RecipientTypeDetails linkedmailbox | %{
$missinglth = $missingplc = $false
$addresses = $_.emailaddresses | ?{$_.prefixstring -eq "smtp"} |
%{$_.addressstring} | Select-String -Pattern "@(.+)" | %{$_.matches[0].groups[1].value.tolower()}
if($addresses -notcontains "plc.com"){$missingplc = $true}
if($addresses -notcontains "lth.com"){$missinglth = $true}
if($missinglth -or $missingplc) {
New-Object -TypeName psobject -Property @{
name = $_.name
Identity = $_.identity;
Missinglth = $missinglth;
Missingplc = $missingplc
}
}
} | ft name, identity, missinglth, missingplc
|