azure - 导出多个 Azure AD 组成员

标签 azure powershell active-directory azure-active-directory office365

我正在使用下面的代码片段,而不是 -ALL 我试图传递特定的 ObjectId 或过滤器组名称,但出现以下错误。请帮助解决这个问题。

$groups=Get-AzureADGroup -ObjectId "Group1"- 适用于一个 ObjectId,但不适用于多个 ObjectId

$groups=Get-AzureADGroup -filter{Name -like "ABC*"} - Get-AzureADGroup:无法评估参数“Filter”


    Connect-AzureAD
    $groups=Get-AzureADGroup -All $true
    $resultsarray =@()
    ForEach ($group in $groups){
        $members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true 
        ForEach ($member in $members){
           $UserObject = new-object PSObject
           $UserObject | add-member  -membertype NoteProperty -name "Group Name" -Value $group.DisplayName
           $UserObject | add-member  -membertype NoteProperty -name "Member Name" -Value $member.DisplayName
           $UserObject | add-member  -membertype NoteProperty -name "ObjType" -Value $member.ObjectType
           $UserObject | add-member  -membertype NoteProperty -name "UserType" -Value $member.UserType
           $UserObject | add-member  -membertype NoteProperty -name "UserPrinicpalName" -Value $member.UserPrincipalName
           $resultsarray += $UserObject
        }
    }
    $resultsarray | Export-Csv -Encoding UTF8  -Delimiter ";" -Path "C:\scripts\output.csv" -NoTypeInformation

最佳答案

$groups=Get-AzureADGroup -All
$result=new-object system.colletions.arraylist

foreach($group in $groups)
{
    $members=$group.members
    foreach($member in $members)
    {
        $result.add(
            [PSCustomObject]@{
                "Group Name"=$group.DisplayName
                "Member Name"=$member.DisplayName
                "ObjType"=$member.ObjectType
                "UserType"=$member.UserType
                "UserPrinicpalName"=$member.UserPrincipalName
        }) > $null
    }
}

如果您想搜索特定组,可以使用-SearchString 'groupName' 或组列表:

$groups='group1,group2,group3'.split(',')|%{
    Get-AzureADGroup -SearchString $_
}

关于azure - 导出多个 Azure AD 组成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66513291/

相关文章:

Apache/Tomcat - 基于 AD 组成员资格的 LDAP 身份验证

azure - Update 3 后 Visual Studio 2013 Premium 解决方案加载错误

Azure Web功能: Create binding from http request to inputBlob path

azure - 管理员同意不适用于应用程序模型 V2

windows - 在 Windows 上设置 docker 时出错

c# - 通过电子邮件地址在 ActiveDirectory 中查找用户

azure - 如何使用 Azure Active Directory B2C 在 React Native 中进行身份验证?

powershell - 实现 "Press Enter to skip"

powershell - 需要在 PowerShell 脚本中查找并替换字符串的一次出现

asp.net-mvc - Windows Azure Active Directory 单点登录 - 用于登录错误的自定义错误页面