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

lb3vh1jj  于 2023-02-09  发布在  其他
关注(0)|答案(1)|浏览(140)

我需要在我的终端中得到一个列出所有用户及其特定属性的表。我使用的powershell是通过命令Install-Module AzureADConnect-AzureAD -Tenant "<mydirectory>.onmicrosoft.com"设置的。
当我查询单个用户时,我得到以下信息:

О»  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-...

现在我需要输出一个所有用户的表,所以我列出了它的objectIdextension_<largenumber>_customerId和一个email字段,注意我有数百万的用户(结果应该被转储到一个文件中)。

x3naxklr

x3naxklr1#

通过运行以下命令,可以使用样例ObjectID(例如您自己的ObjectID)查看要过滤的所有特性:

Get-AzureADUser -ObjectId example@contoso.com | select *

在确定了所需的过滤器后,您将使用一些附加标志:

  • 对所有用户运行-all $true
  • > results.csv转储到csv文件
  • Format-Table -AutoSize,用于强制表输出(如果您决定包含AzureADUser的五个以上属性

试着用这样的东西作为你的起点。

Get-AzureADUser -all $true | select ObjectID, mail, extension_<largenumber>_customerId  | Format-Table -AutoSize > C:\output\results.csv

根据需要命名输出文件和位置。
您还应该考虑缩小搜索范围,因为您的搜索对象是一百万用户。请考虑缩小搜索范围。也许您可以只搜索特定电子邮件域、公司或部门中的用户?
我不确定这个脚本对一百万条用户记录的查询会有什么微不足道的影响。也许有经验的人可以发表评论。

相关问题