PowerShell – Fix Missing msExch Attributes in Get-ADUser Filter

exchange-2010powershell

I'm a domain admin trying to create an export of all AD users, recording all msExch attributes (Exchange 2010).

The following works fine:

Get-ADUser <sAMAccountName> -Properties * | Select name, *msexch*

The following doesn't:

Get-ADUser -Filter * -Properties * | Select name, *msexch*

Instead I get a column named msexch with no value

What am I missing?

Best Answer

It should work after you add the searchbased to narrow down on your scope. Get-ADUser -searchbase "OU=ParentOU,OU=All Users,DC=domain.DC=local" -Filter * -Properties * | Select name, msexch

I find similar issues as you if a searchbase is not specified while your filter is wild open "eg. *"