Posts

Showing posts with the label Power Shell Script For Creating Bulk Users in Active Directory

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}