Import-Csv .\usercreationfile.csv | foreach-object {
$userprinicpalname = $_.SamAccountName + “@{domainname}.com”
New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpalname -Name $_.name -DisplayName $_.name -GivenName $_.cn -SurName $_.sn -Department $_.Department -Path “CN=Users,DC=biogen,DC=com” -AccountPassword (ConvertTo-SecureString “Microsoft~1;” -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru }
You can use the below powershell query to create bulk users in AD. The user names should be imported from .csv files.
Code:Import-Csv .\usercreationfile.csv | foreach-object { $userprinicpalname = $_.SamAccountName + “@{domainname}.com” New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpalname -Name $_.name -DisplayName $_.name -GivenName $_.cn -SurName $_.sn -Department $_.Department -Path “CN=Users,DC=biogen,DC=com” -AccountPassword (ConvertTo-SecureString “Microsoft~1;” -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru }