Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

ForEach Object separate

$
0
0

OK, so I’ve got this listing all the groups in an OU that are global groups. I got the earlier examples and changed it around. Thank you. I want to pipe these results into Get-ADGroupMember. At the moment it’s listing all the members of all groups in one big list.

Chaos

I’m looking to do it on a per object basis, like this

Let’s say it pulls Group1, Group2 and Group3 from the OU searching

Instead If listing all members of all three groups in a list, it would be better If it did

Group1

John

Dave

Amy

Group2

Michael

Jake

Mark

$Group = (Get-ADGroup -Filter '*' | select-object * | where-object {$_.distinguishedname -like "*OU*" -and $_.GroupScope -eq "Global"}).Name | Sort-Object ForEach ($Group in $Groups) { (Get-ADGroupMember -Id $Group).Name } 

submitted by /u/wdz
[link] [comments]

The post ForEach Object separate appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793