# Get-ADGroupMember question

**URL:** <https://forums.powershell.org/t/get-adgroupmember-question/16438>\
**Category:** PowerShell Help\
**Created:** [May 5, 2021, 4:06pm UTC](https://forums.powershell.org/t/get-adgroupmember-question/16438 "2021-05-05T16:06:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derekmb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/derekmb/32/1283_2.png) [@Derekmb](https://forums.powershell.org/u/Derekmb)\
**Post date:** [May 5, 2021, 4:06pm UTC](https://forums.powershell.org/t/get-adgroupmember-question/16438/1 "2021-05-05T16:06:14Z")

</div>

Hi  
I am using Get-ADgroupMember piped into Get-ADuser to get a report. The Select portion gives me everything I need except the group name which I would like in the first column, is there any way to do that.  
Here is my code:

```auto
$adGroupList = 'BI_FINANCE_F'
foreach ($group in $adGroupList)
{
    $group
       Get-ADGroupMember -identity $group -Recursive | Get-ADUser -Properties * | select displayname, name, employeeID, Department, title, physicalDeliveryOfficeName, Manager, sAMAccountName, givenName, surname, UserPrincipalName | Export-Csv -Append "C:\temp\GetADGroupMember3.csv" -NoTypeInformation -Encoding UTF8 ##| Select Name,ObjectClass,DisplayName
  
}

```

Thanks,  
Derek

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 5, 2021, 4:18pm UTC](https://forums.powershell.org/t/get-adgroupmember-question/16438/2 "2021-05-05T16:18:03Z")

</div>

Welcome to the forums @Derekmb

Could you please format your code with the code tags \</\> here in the forum? The previous post can be updated. Thanks in advance.

To answer your question, you either need to generate a new object or use a calculated expression. Since most of the properties are coming from one cmdlet, a calculated expression is the easiest to implement:

```auto
$adGroupList = ‘BI_FINANCE_F’
$results = foreach ($group in $adGroupList) {
    Get-ADGroupMember -identity $group -Recursive | 
        Get-ADUser -Properties * | 
            select @{Name='Group';Expression={$group}},
                   displayname,
                   name,
                   employeeID,
                   Department,
                   title,
                   physicalDeliveryOfficeName,
                   Manager,
                   sAMAccountName,
                   givenName,
                   surname,
                   UserPrincipalName
}

$results | Export-Csv -Append “C:\temp\GetADGroupMember3.csv” -NoTypeInformation -Encoding UTF8

```

---

<div class="post-metadata">

**Author:** ![Derekmb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/derekmb/32/1283_2.png) [@Derekmb](https://forums.powershell.org/u/Derekmb)\
**Post date:** [May 10, 2021, 1:01pm UTC](https://forums.powershell.org/t/get-adgroupmember-question/16438/3 "2021-05-10T13:01:53Z")

</div>

Hi Rob,  
I went back to add the code tags and it seemed someone had already done it.  
I’ll make sure to add them in the future.

Thanks again,  
Derek

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:26pm UTC](https://forums.powershell.org/t/get-adgroupmember-question/16438/4 "2024-05-16T20:26:25Z")

</div>

Closed on May 16, 2024, 8:26pm UTC


