The topic made sense in my head before I typed it…
On a scale of 1-10, I’m about a 3 with Powershell (more than a beginner, but less than intermediate).
I have a rudimentary script which dumps ADGroupMembers to CSV and looks something like this:
Get-ADGroupMember "Late Shift" | Select distinguishedName | Export-Csv "c:\reports\LateShift.csv" -NoTypeInformation Get-ADGroupMember "Mid Shift" | Select distinguishedName | Export-Csv "c:\reports\MidShift.csv" -NoTypeInformation Get-ADGroupMember "Early Shift" | Select distinguishedName | Export-Csv "c:\reports\EarlyShift.csv" -NoTypeInformation
(This is only an example. My actual script runs one line for each of 60 groups.)
I’ve since created a new group which contains the other groups. Let’s call it “Shifts”.
When I run
Get-ADGroupMember Shifts | Select Name, I get a list of the other groups. I’d like to loop through that list and get the memberlist of those groups. I started with this:
$Group = Get-ADGroupMember Shifts | Select Name foreach ($Name in $Group) { Write-Host "Processing" $Name }
The output:
Processing @{Name=Early Shift} Processing @{Name=Late Shift} Processing @{Name=Mid Shift}
What should I be doing to get the correct group name passed through the loop?
Thx!
Robb