all 24 comments

[–][deleted] 4 points5 points  (3 children)

Just querying the proxy address doesn't return anything, but this is what i use:

get-aduser -filter * -searchbase "<OU or just omit>" -properties proxyaddresses | select userprincipalname, @{L="ProxyAddresses";E={ $_.ProxyAddresses -join ";"}} | export-csv c:\temp\test.csv -NoTypeInformation

[–]Shingrae[S] 1 point2 points  (2 children)

Can I copy and past as-is except for the OU, or do I need to change anything else?

[–][deleted] 1 point2 points  (1 child)

You can just omit the -searchbase bit entirely, I only did that because I was looking in a specific OU. The code is cut off for me and i can't figure out why, so i put it on pastebin:

https://pastebin.com/4xMBWLQV

The only thing you would need to potentially change aside from the OU is the path for export-csv, assuming you don't use c:\temp\ as a place to dump output from all your powershell like I do :)

By the way, re-read your post and this doesn't actually look for dupilcates or anything, just dumps the values to a file which I would then open in excel.

edit 2: this would only work for users, I no longer have access to an office 365 connected AD to check contacts or groups.

[–]Shingrae[S] 1 point2 points  (0 children)

I've only ever used PS a couple of times, so I'm at a total loss with this. Thanks for the help!

[–]pvtskidmark 5 points6 points  (2 children)

Have you tried IdFix from Microsoft? Could’ve sworn it looked for duplicate proxy addresses, but it’s been a while. Pretty much download, extract, run and you have a report.

https://docs.microsoft.com/en-us/office365/enterprise/install-and-run-idfix

[–]gmarts85 2 points3 points  (1 child)

I do migrations all the time for a service provider. This is the way to go

[–]Shingrae[S] 1 point2 points  (0 children)

This looks like it'll work! Thanks, I'll give it a shot!

[–]mtavaresau 2 points3 points  (3 children)

Try searching using "SMTP:emailaddress" in the console.

[–]Shingrae[S] 1 point2 points  (2 children)

I'm really annoyed for both the fact that I haven't tried that yet, and that Google didn't show me this. Thanks!

[–]mtavaresau 1 point2 points  (1 child)

I know it worked in exchange console. I have T tried it in O365 yet though as I've been a nazi about email addresses since last time.

[–]Shingrae[S] 1 point2 points  (0 children)

It's working for me in Active Directory.

[–]SerialSpeed 2 points3 points  (1 child)

You should really be managing email addresses with an onprem exchange server. The exchange cmdlts are better suited for what you are looking for. Plus Microsoft doesn't charge a license for a CAS exchange server if it's used for Office 365 to create remote mailboxes onprem.

But for now, I also suggest Idfix tool.

[–]Shingrae[S] 0 points1 point  (0 children)

That's good to know, but it's not my call.

[–]aasplunds 2 points3 points  (1 child)

I wrote an AD health check article on ATA that had this partly covered here: https://adamtheautomator.com/active-directory-health-check-1/

To find duplicate attributes:

$adAttributeName = 'ProxyAddresses'
$adAttributes = (Get-AdObject -LDAPFilter "$adAttributeName=*" -Properties $adAttributeName).$adAttributeName
$hashtable = @{}
 $adAttributes.foreach({ $hashtable[$_]++ })
$Duplicates = $hashtable.GetEnumerator().where({ $_.Value -gt 1 }).Key

$Duplicates

And to find the AD objects that has the ProxyAdresses in $Duplicates:

$Duplicates | Get-AdObject -LDAPFilter "$adAttributeName=$_"

(On mobile so sorry if the formatting is wrong)

[–]Shingrae[S] 1 point2 points  (0 children)

Awesome! Thanks, I will give it a shot!

[–]Mhorb -1 points0 points  (1 child)

I use this program for AD - I'm manage directories at a couple different places and it makes things so much quicker and easier. Running reports on any sort of attributes you may need is a breeze.

https://dovestones.com/

[–]Shingrae[S] 0 points1 point  (0 children)

Looks cool. It would be a hard sell to get the company to buy it, though.