Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Query Azure Active Directory For UPN and Primary SMTP Address then export to CSV

$
0
0

I am trying to get a csv containing two columns, UPN and Primary SMTP Address.  The primary SMTP address is among other addresses in the ProxyAddresses property and is discernible because the SMTP is all caps, and the secondaries are all lowercase.

 

So far this is what I have, which returns all of the SMTP addresses in ProxyAddresses column and not just the Primary address with the SMTP: prefix

 

     $licusers = gc .\licuser_trim.txt

     FOREACH ($user in $licusers)

     {

     Get-MSOLUser -UserPrincipalName $user | Select userprincipalname, Proxyaddresses | ? {$_.ProxyAddresses -cmatch '^SMTP\:.*'} 

     }


Viewing all articles
Browse latest Browse all 6937

Trending Articles