In Windows Server 2008 Launch Powershell
import-module activedirectory
Check the modules installed:
Get-Module -ListAvailable
import-csv names.csv | new-aduser
import-csv -delim ";" -path "C:\import.csv"
$users = import-csv -delim ";" -path "C:\import.csv"
foreach($user in $users)
{
$pass = $user.Password
$nom = $user.SamAccountName
$prenom = $user.SamAccountName
$displayname = $nom
$login = $user.SamAccountName
$ou = "OU=30 mins,OU=2GB,DC=winopad,DC=com"
$mail = $user.eMail
New-ADUser -name $displayname -surname $nom -givenname $prenom -displayname $displayname -samaccountname $login -accountpassword (convertto-securestring $pass -asplaintext -force) -Path $ou -EmailAddress $mail -enabled $true
}
$users = import-csv -delim ";" -path "C:\test\UsersToBeCreated.csv"
foreach($user in $users)
{
$pass = "Password2011"
$nom = $user.Surname
$prenom = $user.GivenName
$displayname = $prenom+" "+$nom
$login = $user.SamAccountName
$ou = "OU=" + $user.OU +",OU=UTILISATEURS,DC=domain,DC=local"
$description = $user.Description
$fonction = $user.Fonction
$mail = $user.Mail
$drive = $user.Share
$directory = $user.DirectoryShare+$login
$phone = $user.PhoneNumber
New-ADUser -name $displayname -surname $nom -givenname $prenom -displayname $displayname -samaccountname $login -accountpassword (convertto-securestring $pass -asplaintext -force) -Path $ou -description $description -title $fonction -EmailAddress $mail -HomeDrive $drive -HomeDirectory $directory -OfficePhone $phone -enabled $true
}
No comments:
Post a Comment