I am tasked with getting a complete list of users from two different AD Groups. i.e. Group-A “VPN” and are also in Group-B “DEN”. I would also like to export the list with the name of the user and email address. Is this possible? I did see previous postings like this:
$groups = "VPN","DEN" $resultsarray =@() foreach ($group in $groups) { $resultsarray += Get-ADGroupMember -Id $group | select samaccountname,name,@{Expression={$group};Label="Group Name"} } $resultsarray
But it outputs into two separate lists.
samaccountname name Group Name -------------- ---- ---------- usera Test User A VPN userb Test User B VPN usera Test User A DEN userb Test User B DEN
I would like to output all on one line, something like this:
samaccountname name Group A Group B -------------- ---- ---------- --------- usera Test User A VPN DEN userb Test User B VPN DEN
Any assistance would be much appreciated!!!