英文:
Get a table of Azure AD B2C users with custom attributes
问题
我需要在我的终端中获取一个列出所有用户及其特定属性的表格。
我使用了通过命令 `Install-Module AzureAD` 和 `Connect-AzureAD -Tenant "<mydirectory>.onmicrosoft.com"` 进行设置的 PowerShell。
当我查询单个用户时,我得到了以下结果:
О» Get-AzureADUser -ObjectId dacbdd03-... | Select -ExpandProperty ExtensionProperty
Key Value
odata.metadata https://graph.windows.net/ee26ec1a.../$metadata#directoryObjects/@Element
odata.type Microsoft.DirectoryServices.User
createdDateTime 31.01.2023 19:57:55
employeeId
onPremisesDistinguishedName
userIdentities []
extension_
现在我需要输出所有用户的表格,所以我列出了它们的 `objectId`,`extension_<largenumber>_customerId` 以及一个电子邮件字段。请注意,我有数百万用户(结果应导出到一个文件)。
英文:
I need to get in my terminal a table that lists all users together with certain attributes.
I use powershell that was set up using commands Install-Module AzureAD
and Connect-AzureAD -Tenant "<mydirectory>.onmicrosoft.com"
.
When I inquiry a single user, I get this:
О» Get-AzureADUser -ObjectId dacbdd03-... | Select -ExpandProperty ExtensionProperty
Key Value
--- -----
odata.metadata https://graph.windows.net/ee26ec1a.../$metadata#directoryObjects/@Element
odata.type Microsoft.DirectoryServices.User
createdDateTime 31.01.2023 19:57:55
employeeId
onPremisesDistinguishedName
userIdentities []
extension_<largenumber>_customerId 48f6eadf-...
I need now to output a table of all users, so I list its objectId
, extension_<largenumber>_customerId
and also an email field. Note that I have millions of users (result should be dumped in a file).
答案1
得分: 1
以下是翻译好的部分:
-
Get-AzureADUser -ObjectId example@contoso.com | select *
Get-AzureADUser -ObjectId example@contoso.com | select *
-
-all $true
to run against all users-all $true
以针对所有用户运行
-
> results.csv
to dump to a csv file> results.csv
以导出到 CSV 文件
-
Format-Table -AutoSize
to force table output, if you decide to include more than five properties of an AzureADUserFormat-Table -AutoSize
以强制表格输出,如果您决定包含 AzureADUser 的超过五个属性
-
Get-AzureADUser -all $true | select ObjectID, mail, extension_<largenumber>_customerId | Format-Table -AutoSize > C:\output\results.csv
Get-AzureADUser -all $true | select ObjectID, mail, extension_<largenumber>_customerId | Format-Table -AutoSize > C:\output\results.csv
-
Name the output file and location as you'd like.
- 根据您的喜好命名输出文件和位置。
-
You should also consider narrowing down your search as you're running against a million users. Consider narrowing down your search definition. Perhaps you can search for only users in a particular email domain, company, or department?
- 由于您要查询百万用户,您还应考虑缩小搜索范围。考虑缩小搜索定义。也许您只想搜索特定电子邮件域、公司或部门的用户?
-
I'm not sure of any negligible impact this script could have querying against a million user records. Perhaps someone with more experience could comment.
- 我不确定这个脚本对查询百万用户记录可能会有多大影响。也许有经验的人可以发表评论。
英文:
You can review all properties to filter by using an example ObjectID (such as your own) by running the following:
Get-AzureADUser -ObjectId example@contoso.com | select *
After you know what filters you'd like, you'll use a few additional flags:
-all $true
to run against all users> results.csv
to dump to a csv fileFormat-Table -AutoSize
to force table output, if you decide to include more than five properties of an AzureADUser
Try using something like this as your starting point.
Get-AzureADUser -all $true | select ObjectID, mail, extension_<largenumber>_customerId | Format-Table -AutoSize > C:\output\results.csv
Name the output file and location as you'd like.
You should also consider narrowing down your search as you're running against a million users. Consider narrowing down your search definition. Perhaps you can search for only users in a particular email domain, company, or department?
I'm not sure of any negligible impact this script could have querying against a million user records. Perhaps someone with more experience could comment.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论