The Exchange 2007 Wiki

Bulk Create Mailboxes

Description

This script can be used to bulk create mailbox users. The data required to create these users is obtained from a comma separated variable (CSV) file of a particular format. A sample CSV file is here.

Usage

Save the script code below into a simple text file and name it BulkCreateMailboxes.ps1. Open up the Exchange Management Shell and navigate to the directory containing the file you just created. Type:
.\BulkCreateMailboxes.ps1 C:\MBinfo.csv
Ensure the path specified for the CSV file is correct.
Sample Script

## 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
}

 

Disclaimer: The sample scripts are meant to serve as examples and may need modifications before they will work in your environment. The authors of the script are not responsible for any negative outcome that may result from using them. 

Site

Changes
Index
Search

 

User

 

Log In
Register

 
 

Last Modified 10/12/07 12:26 PM