Share via


How to Use Templates to Create Recipients

Microsoft Exchange Server 2007 will reach end of support on April 11, 2017. To stay supported, you will need to upgrade. For more information, see Resources to help you upgrade your Office 2007 servers and clients.

 

Applies to: Exchange Server 2007, Exchange Server 2007 SP1, Exchange Server 2007 SP2, Exchange Server 2007 SP3

This topic explains how to use the Exchange Management Shell to create recipients by using an existing recipient as a template. Using a recipient template is an efficient way to provision recipients in a consistent manner without having to explicitly specify all configuration settings.

Note

You cannot use the Exchange Management Console to create recipients by using templates.

In addition to providing consistency and simplifying configuration, using a recipient template also allows you to configure settings for a recipient that are not available in a New- cmdlet. For example, assume you use a designated expansion server for all distribution groups in your organization. Normally, to set the expansion server for a new distribution group, you would need to use the Set-DistributionGroup cmdlet in the Exchange Management Shell or the Advanced tab of the distribution group properties in the Exchange Management Console. You can achieve the same result by using a distribution group that already has the expansion server attribute configured as a template in the New-DistributionGroup cmdlet.

Using recipient templates also allows you to provision non-standard recipients. Consider the following scenario: You want to configure the mailboxes for your interns to have smaller storage quotas and message size restrictions than what is standard for your organization. Also, you do not want to retain their deleted items. One way to achieve this is to create all the intern mailboxes in a separate mailbox database and configure the settings at the mailbox database level. However, if you want to avoid creating an additional mailbox database, you can achieve the same result by using a template mailbox to provision the intern mailboxes. You can configure the template mailbox based on the intern mailbox profile and use it as a template in the New-Mailbox cmdlet when provisioning new mailboxes for interns.

Important

While you can use an existing recipient as a template when creating new recipients, you can also maintain specific recipients that are dedicated to this purpose. Because such recipients would not be associated with a real person, resource, or group, you should secure them to minimize the risks that are associated with having a generic account. For more information about securing recipients that are only used as templates, see How to Secure Recipient Templates.

To learn more about using templates to clone objects, see Templates.

Before You Begin

To perform the following procedures, the account you use must be delegated the following:

  • Exchange Recipient Administrator role

  • Account Operator role for the applicable Active Directory containers

For more information about permissions, delegating roles, and the rights that are required to administer Microsoft Exchange Server 2007, see Permission Considerations.

Also, before you perform these procedures, be aware that you can use the following cmdlets in the Exchange Management Shell to create recipients by using a template:

  • New-DistributionGroup

  • New-DynamicDistributionGroup

  • New-Mailbox

  • New-MailContact

  • New-MailUser

All of these cmdlets implement the TemplateInstance parameter. To use a template to create a new recipient, you must pass the recipient object you want to use as a template to the TemplateInstance parameter.

Note

When you use a template to create a new recipient, all properties are copied to the new recipient, except the mandatory properties for the corresponding New- cmdlet, and the properties that must be unique in the organization.

Procedure

To create a new mailbox by using a mailbox template

  1. Start the Exchange Management Shell.

  2. Run the following commands to create a new mailbox for John Smith by using the mailbox Template1 as the mailbox template. The first command retrieves the mailbox template and stores it in the temporary variable $Template. The second command uses the mailbox template to create the mailbox.

    $Template = Get-Mailbox "Template1"
    New-Mailbox -Name "John Smith" -UserPrincipalName "jsmith@contoso.com" -Database "Server1\Mailbox Database" -OrganizationalUnit "contoso.com/Users" -TemplateInstance $Template
    
  3. Enter the password for the new user when prompted.

To create multiple mailboxes by using a list and a mailbox template

  1. To take the previous example one step further, you can create multiple mailboxes based on a mailbox template by using a single command. The same mailbox, Template1, is used as the mailbox template. This procedure assumes that you have the comma-separated value (CSV) text file that has a list of mailboxes you want to create, as shown in the following example:

    Name,UPN,OU,Password
    Deepak Kumar,DKumar@contoso.com,contoso.com/Users,pass@word1
    Ray Chow,RChow@contoso.com,contoso.com/Users,pass@word1
    David Simpson,DSimpson@contoso.com,contoso.com/Users,pass@word1
    Isabel Martins,IMartins@contoso.com,contoso.com/Users,pass@word1
    
  2. Start the Exchange Management Shell.

  3. Run the following commands to create new mailboxes listed in the CSV file, using the mailbox Template1 as the mailbox template. The first command retrieves the mailbox template and stores it in the temporary variable $Template. The Import-CSV command reads the contents of the NewUsers.csv file. The content of the CSV file is then piped into the ForEach-Object command, which executes a script block to create the new mailboxes for each line item listed in the CSV file. The ConvertTo-SecureString command in the script block converts the plain text password in the CSV file to a secure string and stores it in the temporary variable $Temp. The New-Mailbox command creates the new mailbox and uses the $Temp variable to create the password for the new user.

    $Template = Get-Mailbox "Template1"
    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}
    

    For more information about using scripts in the Exchange Management Shell, see Scripting with the Exchange Management Shell.

To create a new distribution group by using a distribution group template

  • Run the following commands to create a new distribution group by using the distribution group DGTemplate as the template. The first command retrieves the distribution group template and stores it in the temporary variable $Template. The second command creates the new distribution group.

    $Template = Get-DistributionGroup "DGTemplate"
    New-DistributionGroup -Type Distribution -SamAccountName DG1 -Name DG1 -OrganizationalUnit "contoso.com/Users" -TemplateInstance $Template
    

For More Information

To learn more about recipients, see Understanding Recipients.

For more information about the pipelining feature in the Exchange Management Shell, see Pipelining.

For more information about the management interfaces in Exchange 2007, see Management Interfaces.