How to import CSV to add different users to different group in one time??????


hi, simple question cannot search answer, so ask here.

created 50 new ad global groups , each group has different membership, can add users groups powershell in 1 time? could you kindly give me script template can run? thanks.

i.e. import csv
group name, members
gp001, has member a1, a2, a3
gp002, has member a1, a2, a4
gp003, has member a1, a3, a4

if rename csv header "group name", "group", code work. 

$csv = import-csv groups.csv foreach ($line in $csv) {     $memberarray = $line.members -split '\s*,\s*'     add-adgroupmember -identity $line.group -members $memberarray -whatif     }

note:  never idea have spaces in header of csv.

grant ward, a.k.a. bigteddy




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Round Robin is killing performance on our network

WMI Repository 4GB limit - Win 2003 Ent Question

Change home folder default permission?