Assuming we have a list of email groups (e.g.): [array]$Groups=("foo","bar","bing")
How can we include each group's name with output from: Get-DistributionGroupMember
(e.g.): $Groups | Get-DistributionGroupMember | select alias,[group name that was piped]
I know the answer is right in front of me, I just can't see it! thanks!
CodePudding user response:
ok... this works!
foreach ($group in $groups) {
Get-DistributionGroupMember $group | select alias, @{N='groupname';E={$group}}
}
If there's a better or alternate strategy for similar situations feel free to share!
- updated to remove "-PipelineVariable $group" per AdminOfThings comment