Solved

Get Groups from AD Accounts and the nested groups

Posted on 2016-09-22
3
52 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.
A brief introduction to what I consider to be the best editor for PowerShell.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 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