Created
December 14, 2016 23:49
-
-
Save chrisbrownie/fd0a1ead26ff5044fe4d2c6b61a10c08 to your computer and use it in GitHub Desktop.
Gets UPN, Mail, and primary SMTP address (from proxyAddresses)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show all | |
Get-ADUser -ldapFilter '(msExchMailboxGuid=*)' -Properties mail,UserPrincipalName,ProxyAddresses | | |
Select UserPrincipalName,mail,@{N="PrimarySmtpAddress";E={($_.proxyAddresses | Where {$_ -clike "SMTP:*"}).Split(":")[1]}} | |
# Show only where there is a mismatch | |
Get-ADUser -ldapFilter '(msExchMailboxGuid=*)' -Properties mail,UserPrincipalName,ProxyAddresses | | |
Select UserPrincipalName,mail,@{N="PrimarySmtpAddress";E={($_.proxyAddresses | Where {$_ -clike "SMTP:*"}).Split(":")[1]}} | | |
Where { | |
($_.mail.ToString() -ne $_.userPrincipalName.ToString()) -or | |
($_.mail.ToString() -ne $_.PrimarySmtpAddress.ToString()) -or | |
($_.UserPrincipalName.ToString() -ne $_.PrimarySmtpAddress.ToString()) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment