Created
September 12, 2017 02:06
-
-
Save kevinblumenfeld/cb4a48e9d634847c7b734587aee37735 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
Get-ADUser -Filter 'proxyaddresses -ne "$null"' -ResultSetSize $null -Properties DisplayName, samaccountname, UserPrincipalName, proxyAddresses, Distinguishedname -searchBase "DC=CONTOSO,DC=local" | | |
select DisplayName, samaccountname, UserPrincipalName, | |
@{n = "OU" ; e = {$_.Distinguishedname | ForEach-Object {($_ -split '(OU=)',2)[1,2] -join ''}}}, | |
@{n = "PrimarySMTP" ; e = {( $_.proxyAddresses | ? {$_ -cmatch "SMTP:*"}).Substring(5) -join ";" }}, | |
@{n = "smtp" ; e = {( $_.proxyAddresses | ? {$_ -cmatch "smtp:*"}).Substring(5) -join ";" }}, | |
@{n = "x500" ; e = {( $_.proxyAddresses | ? {$_ -match "x500:*"}).Substring(0) -join ";" }}, | |
@{n = "SIP" ; e = {( $_.proxyAddresses | ? {$_ -match "SIP:*"}).Substring(4) -join ";" }} | | |
Export-Csv ADUsers.csv -NTI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment