Powershell - Batch Update AD User Object > Member Of Tab

I have over 80 users that I need to update their "Member Of" field in their AD User Object > Member Of Tab

I have two GPOs to add, possibly three.

The users are in a txt and CSV file.

Is there a PS script that will process the update?
Mike DiasAsked:
Who is Participating?
 
Mike DiasAuthor Commented:
Found it. Thanks.

$grp = 'GIT_GS_AMU_Windows7_Object '

Import-Module ActiveDirectory 
$comps=Get-Content names.txt 

$grpDN = (get-adgroup $grp).distinguishedname

foreach ($comp in $comps)
{$dns=get-aduser $comp
$b=$dns.distinguishedname
Add-ADGroupMember -Identity  $grpDN -member $dns 
}

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Import-Csv GroupMembers.csv | % { Add-ADGroupMember $_.Group -Member $_.User }

Open in new window

If the csv fle has rhe columns Group and User, and only a single user per row.
0
 
Mike DiasAuthor Commented:
Thanks for this. I'll try this tomorrow.
0
 
Mike DiasAuthor Commented:
Script based and solves the issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.