Home > Exchange 2007 > Create Bulk Test Users in Exchange 2007 with Exchange PowerShell

Create Bulk Test Users in Exchange 2007 with Exchange PowerShell

I just built my first Exchange 2007 Server, I now want to populate it with users accounts and mailboxes.  Here is the process:

1.) Copy the data below into a CSV file on your Exchange 2007 Server.  Name it BulkData.csv and save it to a folder named BulkUsers on the root of the C: drive. (C:\BulkUsers)

Name

Alias

Password

Database

FQDN

OU

New-Hires1

New-Hires1

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

New-Hires2

New-Hires2

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

New-Hires3

New-Hires3

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

New-Hires4

New-Hires4

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

New-Hires5

New-Hires5

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

New-Hires6

New-Hires6

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Sales-1

Sales-1

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Sales-2

Sales-2

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Sales-3

Sales-3

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Accounting-1

Accounting-1

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Accounting-2

Accounting-2

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

Accounting-3

Accounting-3

ABCD1234

Yale-DC01-SG1\Yale-Dc01-sg1-db1

Yale.edu

Users

2.) Copy this script and name it BulkImport.Ps1.

## Import data from csv and store it in variable ‘data’

$data = import-csv $args[0]

## Function to convert password into a secure string

function New-SecureString([string] $plainText)
{
   $secureString = new-object System.Security.SecureString

   foreach($char in $plainText.ToCharArray())
   {
      $secureString.AppendChar($char)
   }

   $secureString
}

foreach ($i in $data)
{

$ss = new-securestring $i.password
$upn = $i.alias + "@" + $i.fqdn
new-mailbox -Password $ss -Database $i.database -UserPrincipalName $upn -Name $i.name -OrganizationalUnit $i.ou
}

3.) Launch Exchange PowerShell with elevated "Administrator" rights.  Issue this command:

.\BulkImport.ps1 C:\BulkUsers\Bulkdata.csv

It should take about a minute to run.  When it is complete, you will see this screen output.  Launch AD Users and Computers and look in the Users OU.  You should now see the new accounts.

image

Advertisements
Categories: Exchange 2007
  1. No comments yet.
  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: