Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get a list a users from a group, then get all of those users group recursive groupmembership

$
0
0

I am stumped on this.. I am close I just cannot figure out how to get the recursive group membership for the list of users

Here is what I am doing, but I have tried this several ways

$group= (get-adgroupmember05225-Recursive).name

foreach ($userin$group) {get-aduser$user-Properties*|Select-Objectname,@{name="MemberOf";expression={$_.memberof }} |Export-CsvC:\temp\lAudit.csv-NoTypeInformation-Append }

This basically gives me a column with the name and the other column with the DN of the groups (I would love to make this the Samaccount name) I tried the following but it didn't work like I wanted.. for one I no longer can have a name column :( just a list a groups for 1110 users..

foreach ($userin$group){ (GET-ADUSER$user–PropertiesMemberOf|Select-ObjectMemberOf).MemberOf |Get-ADGroup|ForEach-Object {$_.Name} }

Basically what I am trying to achieve is get list of users from one group (1110 Users) and then get the recursive group membership for the users in that group. Then export it to an CSV where in one column you have the users and in the other column you have a list of groups(samaccountname).

Any help or if someone can point me in the right direction would be much appreciated. 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles