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