exchange-2007-shell-logo.jpgWhen deploying customer systems I almost never use the default “First Storage Group” and the associated mailbox database, or at the very least will move and rename them to suit the situation. In a lot of cases more than one storage group and mailbox database is required for the customer. Creating these through the Exchange Management Console is a bit of a drag, and so is doing them one by one in the Exchange Management Shell.

Since you’ve pre-planned your Exchange system before installing it (right?) you can also take the time to whip up a script that will create your storage groups and mailbox databases for you while you do something more enjoyable. The script will make use of the New-StorageGroup, New-MailboxDatabase, and optionally the Mount-Database cmdlets.

I’ve uploaded a sample script here:
PowerShell Script

How to run the script:

  1. Download the script file from the link above and save it to your computer
  2. Rename the file extension to .ps1
  3. Launch the Exchange Management Shell
  4. Execute the script by entering the name of the file (eg C:Scriptcreatemailstores.ps1)

The script will output the name of each Storage Group as it is created, and then the name and all of the details of each of the Mailbox Databases as they are created. A 300 second (5 minute) sleep is inserted at the end to try to avoid errors that can appear if you try to mount a database too soon after it has been created.

If any of the databases fail to mount you can wait a few more minutes before trying again. One way of mounting several dismounted databases all together is to pipe the Get-MailboxDatabase cmdlet into the Mount-Database cmdlet like so:

Get-MailboxDatabase | Mount-Database

Because all of the databases are created with the MountAtStartup attribute set to True you can also mount all of the databases by restarting the Microsoft Exchange Information Store service like so:

[PS] C:\>Restart-Service MSExchangeIS
WARNING: Waiting for service 'Microsoft Exchange Information Store
(MSExchangeIS)' to finish stopping...
WARNING: Waiting for service 'Microsoft Exchange Information Store
(MSExchangeIS)' to finish starting...

You should not use the Restart-Service method if you already have production databases running on the server.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

Leave a Reply