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

后端 未结 30 1664
攒了一身酷
攒了一身酷 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:48

    Old school way from CMD:

    net user mst999 /domain 
    
    0 讨论(0)
  • 2020-12-04 06:48

    Get-QADUser -SamAccountName LoginID | % {$_.MemberOf } | Get-QADGroup | select name

    0 讨论(0)
  • 2020-12-04 06:50

    Get-ADPrincipalGroupMembership will do this.

    Get-ADPrincipalGroupMembership username | select name
    
    name
    ----
    Domain Users
    Domain Computers
    Workstation Admins
    Company Users
    Company Developers
    AutomatedProcessingTeam
    
    0 讨论(0)
  • 2020-12-04 06:50
    (GET-ADUSER –Identity USERNAME –Properties MemberOf | Select-Object MemberOf).MemberOf
    
    0 讨论(0)
  • 2020-12-04 06:50

    If you cannot get Get-ADPrincipalGroupMembership to work for you could try logging in as that user then use.

    $id = [Security.Principal.WindowsIdentity]::GetCurrent()
    $groups = $id.Groups | foreach-object {$_.Translate([Security.Principal.NTAccount])}
    $groups | select *
    
    0 讨论(0)
  • 2020-12-04 06:50

    Get-ADPrincipalGroupMembership USERLOGON | select name

    0 讨论(0)
提交回复
热议问题