Question : Check the smtp of every user in a OU and all below Ou's and get users who do not have both addesses.

Hi,

Check the smtp of every user in a OU and all below Ou's and get users who do not have both addesses.

@plc.com
@lth.com

before the @ would be the user names.

regards
sharath

Answer : Check the smtp of every user in a OU and all below Ou's and get users who do not have both addesses.

Sorry, I left the "linkedmailbox" parameter value from the first line.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
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
Random Solutions  
 
programming4us programming4us