Power Shell Script For Creating Bulk Users in Active Directory

Power Shell Script for creating bulk users from CSV in Active Directory.All the Column name should be available such as SamAccountName,DisplayName,GivenName,Surname and more.

ᐅ Import-Csv .\Users.csv | foreach-object { $userprinicpalname = $_.SamAccountName + "@contoso.com"; New-ADOrganizationalUnit -Name Hardware -Path "ou=IT,dc=dc1,dc=com";New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $userprinicpalname -Name $_.name -DisplayName $_.name -GivenName $_.cn -SurName $_.sn -Department $_.Department -Path $_.path; Set-ADAccountPassword -identity $_.SamAccountName -NewPassword (ConvertTo-SecureString -AsPlainText $_.Password -Force) -Reset ; Enable-ADAccount -identity $_.SamAccountName; Set-ADUser -Identity $_.SamAccountName -ChangePasswordAtLogon $true}

Comments

Popular posts from this blog

Exchange Move Request

Organizational unit blank in Exchange admin center

WINDOWS SERVER 2012 “THE USER PROFILE SERVICE SERVICE FAILED THE LOGON. USER PROFILE CANNOT BE LOADED.” WHEN SIGINING INTO A SERVER THROUGH RDP”.