How to get all groups that a user is a member of?

后端 未结 30 1712
攒了一身酷
攒了一身酷 2020-12-04 05:56

PowerShell\'s Get-ADGroupMember cmdlet returns members of a specific group. Is there a cmdlet or property to get all the groups that a particular user is a member of?

30条回答
  •  失恋的感觉
    2020-12-04 06:31

    First, import the activedirectory module:

    import-module activedirectory
    

    Then issue this command:

    Get-ADGroupMember -Identity $group | foreach-object {
        Write-Host $_.SamAccountName
    }
    

    This will display the members of the specified group.

提交回复
热议问题