GetAduser need Manager name and email in results

This can be accomplished again with a calculated expression doing a sub-query on Active Directory. Depending on how many records you are pulling, try not to do too many as it can impact performance since you are doing individual queries for a single property:

$adGroupList = 'BI_FINANCE_FULL','BI_FIN_EXP_FACILITIES_FULL_R1'
$results = foreach ($group in $adGroupList) {
    Get-ADGroupMember -identity $group -Recursive | 
        Get-ADUser -Properties * | 
            Select-Object @{Name='Group';Expression={$group}},
                   displayname,
                   name,
                   employeeID,
                   Department,
                   title,
                   physicalDeliveryOfficeName,
                   Manager,
                   @{Name='ManagerName';Expression={Get-ADUser -Identity $_.Manager | Select-Object -ExpandProperty DisplayName}},
                   sAMAccountName,
                   givenName,
                   surname,
                   UserPrincipalName
}

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

1 Like