PS Script: List users from several ad-groups with extension attribute 12 in a csv list

Fahrradfahrer1990 1 Reputation point
2021-01-27T10:11:50.633+00:00

Hello dear Team,

im a beginner in scripting and trying to list users from several ad-groups with extension attribute 12 in a csv file. After that i want to filter the users in the csv list after the extension attribute 12.

The part to export users of multiple groups into single file isn´t the problem:

$groups = Get-Content C:\adgroups.txt

$results = foreach ($group in $groups) {
Get-ADGroupMember $group | select samaccountname, name, @{n='GroupName';e={$group}}, @{n='Description';e={(Get-ADGroup $group -Properties description).description}}
}

$results

$results | Export-csv C:\grouplistresult.txt -NoTypeInformation

The problem is to export the users with the additional information of extension attribute 12. I tried with several commands, but somehow this does not work yet.

Anyone who could help?

Thank you in advance.

Greetings
Paul

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,832 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,359 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Fahrradfahrer1990 1 Reputation point
    2021-01-27T16:16:36.74+00:00

    Managed to finish the script by try & error. Thx anyway.

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,491 Reputation points Microsoft Vendor
    2021-01-28T09:58:46.087+00:00

    Hi,

    You can get extensionAttribute12 using get-aduser

    Get-ADGroupMember $group| get-aduser -Properties extensionAttribute12|select samaccountname, name, extensionAttribute12, @{n='GroupName';e={$group}},@{n='Description';e={(Get-ADGroup $group -Properties description).description}}  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments