Bulk Mailbox Provisioning with Random Passwords – Easy PowerShell tricks for Exchange Server 2010

Home > Blogs > Exchange Server > Bulk Mailbox Provisioning with Random Passwords – Easy PowerShell tricks for Exchange Server 2010

Bulk Mailbox Provisioning with Random Passwords – Easy PowerShell tricks for Exchange Server 2010

Like This Blog 0 Mike Pfeiffer
Added by August 13, 2012

In a recent Exchange 2010 class here at Interface, we had a discussion on the topic of provisioning mailboxes with PowerShell. One of the questions that came up is how would you go about creating a bulk mailbox provisioning script that would generate an initial secure random password for each mailbox. As it turns out, this is fairly easy to do with a few PowerShell tricks.

I've written a script for this that will create mailboxes in bulk using a CSV file. After the mailboxes have been created, a report is generated that contains the details for each mailbox, along with the associated password. You can download the script here; the steps on how to use it are outlined below.

To use this script, you need to create a CSV file that will be used to create the mailboxes. The column headers in the CSV file should map to the New-Mailbox cmdlet parameter names you would normally use when creating a mailbox. For this example, I am going to use the following parameters and add them as columns in the CSV; Name, Alias, UserPrincipalName, Database and OrganizationalUnit. Obviously, I won't need to provide a password column as the script will handle that part.

Each field will contain the input value for each parameter. You can create the file in excel and save it in CSV format. Here's a screenshot of the CSV file (saved as c:\users.csv) I am going to use for this example:

The script accepts three parameters; PasswordLength, NonAlphanumericCharacters, and ReportFile. The PasswordLength and NonAlphanumericCharacters parameters are optional parameters. The default password length is set to 8 characters, and the default number of non alpha numeric characters is set to 0. You can override these values as needed to meet your AD password policy requirements. The ReportFile parameter is required and should be the full path to where you want the report to be saved.

Once your CSV file is setup, use the following syntax to create the mailboxes in bulk:

[PS] C:\>.\BulkAddRandom.ps1 -CSVFile c:\users.csv -ReportFile c:\report.csv

After the script is run, open the report file saved to the ReportFile directory to view the password assigned to each mailbox:

Now you can use the report to distribute the passwords to the new users.

Mike Pfeiffer – Microsoft MVP
Interface Technical Training – Director of Unified Communications


Training courses Mike teaches in Phoenix, AZ and online with RemoteLive
Exchange Server Training – EXCH2010: Designing and Implementing Exchange Server 2010
PowerShell Training – PS350EX: PowerShell for Exchange Server
Microsoft Lync Server Training – 10533: Deploying Configuring and Administering Lync Server 2010

Video Training Courses by Mike Pfeiffer:
Exchange Server Course Video – EXCH2010 Designing and Implementing Microsoft Exchange Server 2010
PowerShell Course Video – PS350EX: PowerShell for Exchange Server

Videos You May Like

Creating Users and Managing Passwords in Microsoft Office 365

0 506 3

In this Office 365 training video, instructor Spike Xavier demonstrates how to create users and manage passwords in Office 365.

How to Reset a Windows Client Secure Channel Password

0 1565 3

I’m sure you’ve ran into a situation where a user is attempting to log into a machine but they’re getting prompted that there's no secure password or a secure channel for the client computer to the Domain Controller? Or a user appears to not be getting their Group Policy Settings or their New Group Membership.

Detailed Forensic Investigation of Malware Infections – April 21, 2015

4 485 3

In this IT Security training video, Security expert Mike Danseglio (CISSP / CEH) will perform several malware investigations including rootkits, botnets, viruses, and browser toolbars.

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.