Exchange Server

Using a Template to Create Recipient Objects


In previous articles, I showed you how creating a mailbox template could reduce the amount of work that you have to do in the future when creating new Exchange Mailboxes, all the while making the mailbox creation process less prone to error. That’s just the beginning of what templates are capable of doing though. In this article, I want to show you how you can use templates to create multiple mailboxes simultaneously.

Building a CSV FileU

sing a template simplified the process of creating a mailbox, but there was still some work that you had to do. Although the template filled in a lot of the particulars, you still has to provide the mailbox name, the user principle name, the name of the Exchange Server and the database that would be used to store the mailbox, the organizational unit, and of course the name of the template that you want to base the mailbox on.

Sponsored Content

What is “Inside Microsoft Teams”?

“Inside Microsoft Teams” is a webcast series, now in Season 4 for IT pros hosted by Microsoft Product Manager, Stephen Rose. Stephen & his guests comprised of customers, partners, and real-world experts share best practices of planning, deploying, adopting, managing, and securing Teams. You can watch any episode at your convenience, find resources, blogs, reviews of accessories certified for Teams, bonus clips, and information regarding upcoming live broadcasts. Our next episode, “Polaris Inc., and Microsoft Teams- Reinventing how we work and play” will be airing on Oct. 28th from 10-11am PST.

If after reading my first article, you were thinking that it would be easier to just create mailboxes in the old fashion way, you are right. Of course that’s assuming that you are only creating one mailbox. If you have multiple mailboxes to create, then the process is far easier if you use the template.

Of course the template can’t do everything all by itself. We need a way of providing Exchange with the necessary information about the mailboxes that we are going to create. The easiest way to do this is to create a Comma Separated Value (CSV) file.

You can create a CSV file manually using Notepad, but it is usually easier to use Microsoft Excel. If you look at Figure A, you can see the beginnings of a spreadsheet that I am going to use in conjunction with my template to create new mailboxes. The first thing that I want to show you is the top row of the spreadsheet, which contains my column headings. This row is extremely important, because without it, Exchange won’t know how to interpret the data in the file.

Figure A
The spreadsheet’s header row is very important.

The first piece of information that we are providing is the name of the user account for which the mailbox will be created. Next, we need to provide the User Principle Name (UPN). For all practical purposes, this is the user’s E-mail address. After that, we are providing the user’s Organizational Unit (OU). This is the Active Directory container where the user’s account resides. Finally, we are providing a password for the user.

I mentioned earlier that it was easier to create the necessary CSV file using Excel than it was to create the file manually. Part of the reason for that is that Excel allows you to copy and paste a cell’s contents. The OU and Password fields will be the same for all of our user accounts, so we can just copy and paste them, rather than having to retype them each time. You can see what the completed spreadsheet looks like in Figure B.

Figure B
This is what our completed spreadsheet looks like.

Now, click on the Excel orb (or Jewel, or whatever Microsoft is calling it this week), and choose the Save As | Other Formats option from the menu. Save the spreadsheet as a CSV file named Users.csv. Figure C shows what the file looks like in CSV format.

Figure C
This is what our spreadsheet looks like in CSV format.

Finally, copy the CSV file to your Exchange Server, and open the Exchange Management Shell. The first thing that you must do is to define your template as a template instance named $Template. To do so, enter the following command:

$Template = Get-Mailbox “Template”

Next, we need to import the CSV file and tell Exchange how to use the fields that it contains. You can do so by entering the following command:

Import-CSV “C:\NewUsers.csv” | ForEach-Object -process {$Temp = ConvertTo-SecureString $_.Password -asPlainText -force;New-Mailbox -Name $_.Name -UserPrincipalName $_.UPN -OrganizationalUnit $_.OU -Database “Mailbox Database” -Password $Temp -TemplateInstance $Template}

You can see what these commands look like in action in Figure D.

Figure D
This is what it looks like when we create new user accounts using the template.

If we open the Exchange Management Console and go to the Recipient Configuration | Mailbox container, we can verify that the new mailboxes have been created, as shown in Figure E.

Figure E
The Exchange Management Console verifies the existence of the new mailboxes.


If you attempted to type the commands shown above, you probably realized how tedious it is to enter them. Keep in mind though, that you can easily turn these commands into a script. After doing so, creating new users becomes a matter of simply updating your CSV file and then running the script.

Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

External Sharing and Guest User Access in Microsoft 365 and Teams

This eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by: