Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

List all user attributes (including custom attributes) in a nested/recursive group structure of Active Directory

$
0
0

Hello,

I am new to PowerShell. May I ask for help from someone here? Thanks.

And now I am going to export all AD users belongs to a group called "lg_user" (no matter users are member of this group or its sub-group of this group). Here is my code try to do my task. I successfully get all users under the nested group structure. However, I found that I cannot re-use these result to do another query (to get attributes of these users). Please help.

Import-Module ActiveDirectory
$users=Get-ADGroupMember "CN=lg_user,CN=Users,DC=srv2008,DC=home" -Recursive | Select samaccountname
foreach ($user in $users)
{
echo $user;
$userAttr = Get-ADUser -Properties * -Filter {samaccountname -eq $user};   <---- problem is here!!! I think. Pls help.
}

Thanks.

TangG


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>