27 September,2019 by Tom Collins
Question: How can I get the Active Directory groups for a specific user using Powershell? I'm facing a problem where a user is getting a failed login to a SQL Server. This SQL Server has multiple Active Directory groups attached to it - but I don't have visibility to the members of the groups.
I know I can use the Get-ADGroupMember powershell cmdlet , which would give the member list of a specified Active Directory group, but this would be time - consuming .
Is there a Powershell based method to specify the domain user and return the list of active directory groups which they are a member of ?
Answer: There is powershell cmdlet to the rescue! Get-ADPrincipalGroupMembership
The Get-ADPrincipalGroupMembership cmdlet will return the group membership of the specified user , in the current domain of the logon executing this cmdlet
Example 1 : Return group membership of the specified user
Get-ADPrincipalGroupMembership 'MYID1' | select name
Example 2 : Return group membership of the specified user , but this time run the scan of another trusted domain . Note : using the -server switch
Get-ADPrincipalGroupMembership 'MYID1' -server 'domanin2.net'| select name
For some extra information on using Get-ADPrincipalGroupMembership on another trusted domain read Get-ADPrincipalGroupMembership other domain
Read more on Powershell and Active Directory
How to search a different Active Directory Domain with Powershell ...
How to Export Active Directory Group Members with Powershell Get-ADGroupMember
How to install the Active Directory Module for Windows Powershell ...
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |