PowerShell: Adding Users in Bulk in Active Directory

Introduction:

Put a scenario that you are a junior administrator or a helpdesk that has administrative privilege to create accounts (objects) to a specific Organizational Unit (OU). Then your Data Analytics Team generated information that the demand on the services your organization offers will be high on demand for the next quarter. Management then decide that they need more people to keep up with the forecasted demand.

Human Resources then gave you 200 Hired Employees to process their accounts, you then realize the Active Directory Users and Computer (ADUC) don’t support adding users in bulk. These employee accounts needs be created and ready for use the next day. What do you do?

Fortunately, I have experienced this pain in the neck before and wanted to share how I overcome the challenge to administrators out there that is experiencing the same problem. I show the steps that needs to be followed in the next section:

The Process:

Download the powershell script and the csv file template here.
Note: the csv file template has sample data on it, you can replace them with actual data to create.

  1. Fill in the account information in the csv file, this step is usually taken care of HR.
    Note: for the script to work properly, names in the displayName field in the csv file must contain middle initial. (Ex. Sheen Ismhael A. Lim). No other Dot (.) character must exist except in the middle initial, which is required.
  2. Execute the powershell  script.
    PS C:\Windows\system32> & ‘C:\Users\Sheen Ismhael Lim\desktop\Import-ADUsers.ps1’
    -csvFileLocation ‘C:\Users\Sheen Ismhael Lim\desktop\excelTemplate.csv’
    -organizationUnit “OU=Users,OU=Cagayan De Oro,OU=Offices,DC=limdynasty,DC=com”
    -defaultPassword “Welcome123!”
    -fqdn “limdynasty.com”

    Note: There 4 parameters that the script need to work.
    csvFileLocation: The location of the excelTemplate.csv with the data to import.
    organizationUnit: The distinguished name of Organizational Unit (OU) container to put the new accounts.
    defaultPassword: The default password of the accounts to be created.
    fqdn: is the domain part in the userPrincipalName of the account.
    image

This is the sample output of the script:

image

Hope it helps,

For God and Country!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s