Forum Discussion
PRIME_FIRE
Apr 16, 2021Copper Contributor
How to Fetch All the Group membership for a user in the Domain
I was asked to fetch few user's Group membership Across the Domain. I am trying to do it through the Powershell But did not get any idea.can anyone please help one with that? Thanks Sanjeev
Kevin_Morgan
Apr 16, 2021Iron Contributor
Not sure, in what environment you are looking this functionality.
Use the below command in On-Premises Active Directory.
Get-ADPrincipalGroupMembership UserName | Select Name
Use the below command in Azure Active Directory.
$objectId = (Get-AzureADUser -SearchString "user@contoso.com").ObjectId
Get-AzureADUserMembership -ObjectId $objectId
- Erik_MullinsApr 16, 2021Copper ContributorKevin_Morgan
I have a similar question and Im hoping you can assist since you are familiar with the command Im using.
I would like to have powershell read a list of users (text file is fine) and perform
Get-ADPrincipalGroupMembership UserName | Select Name
for each user. Ideally I would like this to be | Export-CSV with each user in its own column and groups listed underneath. However I will take anything I can get at this point as long as I can tell what groups belong to which user. I have tried Get-content and tried to pass that to an object or variable without any luck. I hope you can assist me because I have a rather large project on my hands and this part of the project is slightly time consuming and I think PS can help but dont know how.