Solved

Get Groups from AD Accounts and the nested groups

Posted on 2016-09-22
3
50 Views
Last Modified: 2016-09-28
Hi EE

Does anyone have a script that will export to cvs all the groups an AD account is a member of ?

but not just direct groups , also the groups that those groups are nested in ..

Account1
MemberOF:
Group1
--Group1 is nested in Group2
--Group2 is nested in Group3
--Group3 is nested in Group4
0
Comment
Question by:MilesLogan
3 Comments
 
LVL 12

Expert Comment

by:Gary Dewrell
ID: 41811371
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41811588
Try this and see if it works for you...
Function Get-Nested ($User){
    Get-ADPrincipalGroupMembership $User | % {
      $_ | Select Name,@{N="ChildGroup";E={$Group.Samaccountname}};$Group = $_
      Get-Nested $_.Name  | Select Name,@{N="ChildGroup";E={$Group.Samaccountname}}
    }
}

Get-Nested UserA | Select * -Unique

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 41820123
thank you Subsun1
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question