简体   繁体   中英

How to retrieve Azure AD users with an alternate email address?

How do I retrieve Azure AD users with an alternate email address tin a CSV file?

I tried this but the CSV AlternateEmailAddresses column is empty.

Get-AzADUser | select AlternateEmailAddresses | export-csv azureadusers.csv

I have tested in my environment.

Please use Get-AzureADUser instead of Get-AzADUser as there continues to be a lack of properties returned when comparing "Get-AzureADUser" vs. "Get-AzADUser"

Please use the below command to export Azure AD users with alternate email address to csv file.

Get-AzureADUser |select UserPrincipalName , @{n='OtherMails'; e={$_.OtherMails -join ' '}} | export-csv azureadusers.csv 

在此处输入图像描述

Reference: https://github.com/Azure/azure-powershell/issues/10497

AzureAD is deprecated and the command "Get-AzureADUser" should not be used when not required. It also use Azure Active Directory Scope and is also deprecated and every scopes should use Graph API.

The way you need to do your query with Az Powershell is like this:

# Get users with alternate emails:
$users = Get-AzADUser -Select "otherMails", "Mail","Id","DisplayName", "UserPrincipalName"
# Selecting users other mails:
$users | Select OtherMail

As you can see, there is alot here not making sense. Why Fetching "otherMails" when it is mapped to "OtherMail" property? MS is not even respecting his own standard...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM