提问人:stubben 提问时间:11/13/2023 最后编辑:stubben 更新时间:11/13/2023 访问量:73
如何导出 Azure AD B2C 用户名?
How do I export Azure AD B2C user names?
问:
在 Azure AD B2C 的“用户”菜单下,概述包含以下列:
Name
User name
User type
Source
Object ID
导出用户时,不会导出用户名。
如何导出用户名?
我已经尝试了 AD 界面中可能发生的事情并搜索了答案。从 2021 年找到了关于同一问题的 1 个问题,但没有答案,https://learn.microsoft.com/en-us/answers/questions/373771/azure-ad-b2c-user-export-missing-mail
答:
请注意:从 Azure 门户 (Azure AD B2C) 导出用户时,会导出用户详细信息,但不会导出用户名/登录名,如 Azure AD B2C 门户的“用户”边栏选项卡及其默认位置所示。
如果从 Azure AD B2C 门户导出用户,则默认情况下,它仅导出 userPrincipalName、displayName、surname、mail、givenName、objectId、userType、jobTitle、department、accountEnabledusageLocation、streetAddress、state、country、physicalDeliveryOfficeName、city、postalCode、telephoneNumber、mobile authenticationPhoneNumber、authenticationAlternativePhoneNumber、authenticationEmail、alternateEmailAddress、ageGroup、consentProvidedForMinor、legalAgeGroupClassification。
因此,您可以使用以下 PowerShell 脚本来获取所有详细信息,包括用户名:
Connect-AzureAD
$users = Get-AzureADUser -All $true
$userData = foreach ($user in $users) {
$UserName = if ($user.SignInNames.Value -contains $null) {
$user.UserPrincipalName
} else {
$user.SignInNames.Value
}
$userProperties = [ordered]@{
userPrincipalName = $user.UserPrincipalName
UserName = $UserName
displayName = $user.DisplayName
surname = $user.Surname
mail = $user.Mail
givenName = $user.GivenName
objectId = $user.ObjectId
userType = $user.UserType
jobTitle = $user.JobTitle
department = $user.Department
accountEnabled = $user.AccountEnabled
usageLocation = $user.UsageLocation
streetAddress = $user.StreetAddress
state = $user.State
country = $user.Country
physicalDeliveryOfficeName = $user.PhysicalDeliveryOfficeName
city = $user.City
postalCode = $user.PostalCode
telephoneNumber = $user.TelephoneNumber
mobile = $user.Mobile
authenticationPhoneNumber = $user.AuthenticationPhoneNumber
authenticationAlternativePhoneNumber = $user.AuthenticationAlternativePhoneNumber
authenticationEmail = $user.AuthenticationEmail
alternateEmailAddress = $user.AlternateEmailAddress
ageGroup = $user.AgeGroup
consentProvidedForMinor = $user.ConsentProvidedForMinor
legalAgeGroupClassification = $user.LegalAgeGroupClassification
}
New-Object -TypeName PSObject -Property $userProperties
}
$userData | Export-Csv -Path "C:\Users\rukmini\Downloads\AzureADB2CUsers.csv" -NoTypeInformation
在我的门户中,“用户”边栏选项卡如下所示:In my portal, Users blade looks like:
导出的 CSV 文件现在包含 UPN 和用户名详细信息:
评论