Powershell - Batch Update AD User Object > Member Of Tab

Mike Dias
Mike Dias used Ask the Experts™
on
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?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
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.

Author

Commented:
Thanks for this. I'll try this tomorrow.
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

Author

Commented:
Script based and solves the issue.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial