获取具有自定义属性的Azure AD B2C用户表格

huangapple go评论76阅读模式
英文:

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__customerId 48f6eadf-...


现在我需要输出所有用户的表格,所以我列出了它们的 `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 &quot;&lt;mydirectory&gt;.onmicrosoft.com&quot;.

When I inquiry a single user, I get this:

О&#187;  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_&lt;largenumber&gt;_customerId                    48f6eadf-...

I need now to output a table of all users, so I list its objectId, extension_&lt;largenumber&gt;_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 以针对所有用户运行
  • &gt; results.csv to dump to a csv file

    • &gt; results.csv 以导出到 CSV 文件
  • Format-Table -AutoSize to force table output, if you decide to include more than five properties of an AzureADUser

    • Format-Table -AutoSize 以强制表格输出,如果您决定包含 AzureADUser 的超过五个属性
  • Get-AzureADUser -all $true | select ObjectID, mail, extension_&lt;largenumber&gt;_customerId | Format-Table -AutoSize &gt; C:\output\results.csv

    • Get-AzureADUser -all $true | select ObjectID, mail, extension_&lt;largenumber&gt;_customerId | Format-Table -AutoSize &gt; 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
  • &gt; results.csv to dump to a csv file
  • Format-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_&lt;largenumber&gt;_customerId  | Format-Table -AutoSize &gt; 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.

huangapple
  • 本文由 发表于 2023年2月8日 23:04:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75387694.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定