Today, we are going to discuss about importing bulk users in Active Directory using PowerShell. We are all knows that we can do anything in PowerShell.
You can check the required parameter for adding AD user. But I’m going to import the below sample fields.
Basic Comment
New-ADUser
-Name “Disply Name”
-GivenName “First Name”
-Surname “Last Name”
-SamAccountName “UserName”
-UserPrincipalName “username@sathiya.io”
-Path “OU=OrganizationUnit,DC=sathiya,DC=io”
-Enabled $true
-PasswordNeverExpires $true
-AccountPassword (ConvertTo-SecureString “password” -AsPlainText -force)
-PassThru
The above script is for adding single user.
Script
1 2 3 4 5 |
Import–Module ActiveDirectory Import–Module ActiveDirectory Import–Csv .\ImportUser.csv | foreach–object { New–ADUser –Name $_.Name –GivenName $_.gn –Surname $_.sn –SamAccountName $_.samAcc –UserPrincipalName $_.UPN –Path $_.Path –Enabled $true –PasswordNeverExpires $true –AccountPassword (ConvertTo–SecureString $_.AccPass –AsPlainText –force) –PassThru } |
Sample CSV file ImportUser.csv
I hope the things are going good :)Cheers!