Managed to finish the script by try & error. Thx anyway.
PS Script: List users from several ad-groups with extension attribute 12 in a csv list
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
2 answers
Sort by: Most helpful
-
-
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.