Solved

Get Groups from AD Accounts and the nested groups

Posted on 2016-09-22
3
37 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

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
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 to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now