How to add users to domain from cvs file ?

Use powershell script.

Import-Module -Name ActiveDirectory
$UsersFilePath=”u.csv” #filename with users details
$users=Import-CSV u.csv
ForEach ($user in $users)
$name=$lname+’ '+$fname
NEW-QADUser -Name $name -LastName $lname -FirstName $fname -UserPassword $pass -sAMAccountName $login -ParentContainer 'gone.local/Users’ -UserPrincipalName $logon
ADD-QADgroupmember -identity $group -Member $login


Cvs file structure



CVS can be generated in excel or Calc

A        B      C      D       E     F

  1. lname,fname,group,login,pass,dir
  2. Kowalski,Jan,group_a,kowalski.jan,1SupmXwn,\\users\jan.kowalski

A2,B2,C2 – Write data

D2 generate login joing cells A2 and B2 – „=LOWER(B2&”.”&A2)”

E2 generate pasword from ASCII chars – 8 chars length „=RANDBETWEEN(1;9)&CHAR(RANDBETWEEN(65;90))&CHAR(RANDBETWEEN(97;122))&CHAR(RANDBETWEEN(97;122)) &CHAR(RANDBETWEEN(97;122))&CHAR(RANDBETWEEN(65;90))&CHAR(RANDBETWEEN(97;122))&CHAR(RANDBETWEEN(97;122))”

F2 generate home dir – „=CONCATENATE(„\\users\”;D2)”

Kategoria: Bez kategorii

Możliwość komentowania została wyłączona.