AD Server - Creating Bulk User

I'll try explain how to create bulk user by using PowerShell and csv file.
For more information you can visit for the following website.

A sample of CSV file is shown below.
====================================================

First Last Company Username Password
sTestF sTestL sTestPCSS sTestU sTest123
===================================================
A sample of Powershell code is shown below.
====================================================

$UserList = Import-Csv -Path 'C:\Users\Administrator\Desktop\CreatingBulkUser\SampleSheet.csv' 

foreach ($User in $UserList) {

     $Attributes = @{

        Enabled = $true
        PasswordNeverExpires = $true
        CannotChangePassword = $true
        Path = "OU=Staff,DC=els,DC=pxxxxxxs,DC=org"

        Name = "$($User.First) $($User.Last)"
        UserPrincipalName = "$($User.Username)@els.pxxxxxxs.org"
        SamAccountName = "$($User.Username)"

        GivenName = $User.First
        Surname = $User.Last
        Company = $User.Company
       
        AccountPassword = $User.Password | ConvertTo-SecureString -AsPlainText -Force


     }

    New-ADUser @Attributes

}


================================================
For more parameters such as Password, First Name, Last Name see below.

New-ADUser
   [-WhatIf]
   [-Confirm]
   [-AccountExpirationDate <DateTime>]
   [-AccountNotDelegated <Boolean>]
   [-AccountPassword <SecureString>]
   [-AllowReversiblePasswordEncryption <Boolean>]
   [-AuthenticationPolicy <ADAuthenticationPolicy>]
   [-AuthenticationPolicySilo <ADAuthenticationPolicySilo>]
   [-AuthType <ADAuthType>]
   [-CannotChangePassword <Boolean>]
   [-Certificates <X509Certificate[]>]
   [-ChangePasswordAtLogon <Boolean>]
   [-City <String>]
   [-Company <String>]
   [-CompoundIdentitySupported <Boolean>]
   [-Country <String>]
   [-Credential <PSCredential>]
   [-Department <String>]
   [-Description <String>]
   [-DisplayName <String>]
   [-Division <String>]
   [-EmailAddress <String>]
   [-EmployeeID <String>]
   [-EmployeeNumber <String>]
   [-Enabled <Boolean>]
   [-Fax <String>]
   [-GivenName <String>]
   [-HomeDirectory <String>]
   [-HomeDrive <String>]
   [-HomePage <String>]
   [-HomePhone <String>]
   [-Initials <String>]
   [-Instance <ADUser>]
   [-KerberosEncryptionType <ADKerberosEncryptionType>]
   [-LogonWorkstations <String>]
   [-Manager <ADUser>]
   [-MobilePhone <String>]
   [-Name] <String>
   [-Office <String>]
   [-OfficePhone <String>]
   [-Organization <String>]
   [-OtherAttributes <Hashtable>]
   [-OtherName <String>]
   [-PassThru]
   [-PasswordNeverExpires <Boolean>]
   [-PasswordNotRequired <Boolean>]
   [-Path <String>]
   [-POBox <String>]
   [-PostalCode <String>]
   [-PrincipalsAllowedToDelegateToAccount <ADPrincipal[]>]
   [-ProfilePath <String>]
   [-SamAccountName <String>]
   [-ScriptPath <String>]
   [-Server <String>]
   [-ServicePrincipalNames <String[]>]
   [-SmartcardLogonRequired <Boolean>]
   [-State <String>]
   [-StreetAddress <String>]
   [-Surname <String>]
   [-Title <String>]
   [-TrustedForDelegation <Boolean>]
   [-Type <String>]
   [-UserPrincipalName <String>]
   [<CommonParameters>]


Comments

Popular posts from this blog

MCAS ProctorCache Setup

My CCNA Useful Links