Created
August 16, 2017 14:38
-
-
Save kevinblumenfeld/0ef60d8e847d460d02a15d1765d5ce8b to your computer and use it in GitHub Desktop.
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
$params = @{ | |
SearchBase = (Get-ADDomain).DistinguishedName | |
Filter = { proxyAddresses -like '*' } | |
Properties = 'Displayname', | |
'SamAccountName', | |
'UserPrincipalName', | |
'ProxyAddresses', | |
'DistinguishedName' | |
} | |
Get-ADUser @params | | |
Select-Object DisplayName, SamAccountName, UserPrincipalName, | |
@{n="OU"; e={ $_.DistinguishedName -replace 'CN=[^=]+,' }}, | |
@{n="PrimarySMTP"; e={ | |
$upn = $_.UserPrincipalName | |
($_.proxyAddresses | Where-Object { $_ -clike 'SMTP:*' -and $_ -ne $upn }) -join ', ' }} | | |
Export-Csv .\primarySMTPnotMatchUPN.csv -NoTypeInformation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment