Share via


New-MailUser

 

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

Use the New-MailUser cmdlet to create a new mail-enabled user.

Syntax

New-MailUser -Name <String> -ExternalEmailAddress <ProxyAddress> -Password <SecureString> -UserPrincipalName <String> [-Alias <String>] [-Confirm [<SwitchParameter>]] [-DisplayName <String>] [-DomainController <Fqdn>] [-FirstName <String>] [-Initials <String>] [-LastName <String>] [-MacAttachmentFormat <BinHex | UuEncode | AppleSingle | AppleDouble>] [-MessageBodyFormat <Text | Html | TextAndHtml>] [-MessageFormat <Text | Mime>] [-OrganizationalUnit <OrganizationalUnitIdParameter>] [-PrimarySmtpAddress <SmtpAddress>] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName <String>] [-TemplateInstance <PSObject>] [-UsePreferMessageFormat <$true | $false>] [-UseRusServer <String>] [-WhatIf [<SwitchParameter>]]

Detailed Description

The New-MailUser cmdlet creates a new mail-enabled user object in the Active Directory directory service.

To run the New-MailUser cmdlet, 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.

Note

Not all user attributes can be set with the New-MailUser cmdlet. You can make additional settings with the Set-User cmdlet.

Parameters

Parameter Required Type Description

ExternalEmailAddress

Required

Microsoft.Exchange.Data.ProxyAddress

The ExternalEmailAddress parameter specifies an e-mail address outside of the organization. E-mail messages sent to the mail-enabled user is sent to this external address.

Name

Required

System.String

The Name parameter specifies the common name (CN) of the mail-enabled user.

Password

Required

System.Security.SecureString

The Password parameter specifies the password used by the mail user to secure his or her account.

UserPrincipalName

Required

System.String

The UserPrincipalName parameter defines the name of a system user in an e-mail address format (for example ted@contoso.com).

Alias

Optional

System.String

The Alias parameter specifies the alias of the user. An alias can contain letters, numbers, and the following punctuation marks and symbols:

  • !

  • #

  • $

  • %

  • ^

  • &

  • *

  • +

  • -

  • .

  • /

  • =

  • ?

  • _

  • {

  • }

  • |

  • ~

Confirm

Optional

System.Management.Automation.SwitchParameter

The Confirm parameter causes the command to pause processing and requires you to acknowledge what the command will do before processing continues. You don't have to specify a value with the Confirm parameter.

DisplayName

Optional

System.String

The DisplayName parameter specifies the name that will be displayed in Microsoft Outlook for the mail user.

DomainController

Optional

Microsoft.Exchange.Data.Fqdn

To specify the fully qualified domain name (FQDN) of the domain controller that writes this configuration change to Active Directory, include the DomainController parameter in the command.

FirstName

Optional

System.String

The FirstName parameter specifies the first name of the mail user.

Initials

Optional

System.String

The Initials parameter specifies the initials of the mail user.

LastName

Optional

System.String

The LastName parameter specifies the last name of the mail user.

MacAttachmentFormat

Optional

Microsoft.Exchange.Data.Directory.Recipient.MacAttachmentFormat

The MacAttachmentFormat parameter specifies the Apple Macintosh Operating System attachment format for messages that are sent to the mail user. The valid values for this parameter are:

  • BinHex

  • UUENCODE

  • AppleSingle

  • AppleDouble

By default, this parameter is set to BinHex. The acceptable values for the MacAttachmentFormat parameter are dependent on the MessageFormat parameter. If the MessageFormat parameter is set to Text, you can only use BinHex or UUENCODE values for this parameter. If the MessageFormat parameter is set to Mime, you can only use BinHex, AppleSingle or AppleDouble values for this parameter.

MessageBodyFormat

Optional

Microsoft.Exchange.Data.Directory.Recipient.MessageBodyFormat

The MessageBodyFormat parameter specifies the message body format for messages that are sent to the mail user. The valid values for this parameter are:

  • Text

  • Html

  • TextAndHtml

By default, this parameter is set to TextAndHtml.

The MessageFormat and MessageBodyFormat parameters are interdependent. If the MessageFormat parameter is set to Mime, the MessageBodyFormat parameter can be set to any valid value. However, if the MessageFormat parameter is set to Text, the MessageBodyFormat parameter can only be set to Text. Therefore, if you want to set this parameter to Html or TextAndHtml, you must also set the MessageFormat parameter to Mime.

MessageFormat

Optional

Microsoft.Exchange.Data.Directory.Recipient.MessageFormat

The MessageFormat parameter specifies the message format for messages that are sent to the mail user.

The valid values for this parameter are:

  • Text

  • Mime

By default, this parameter is set to Mime.

The MessageFormat and MessageBodyFormat parameters are interdependent. If the MessageFormat parameter is set to Mime, the MessageBodyFormat parameter can be set to any valid value. However, if the MessageFormat parameter is set to Text, the MessageBodyFormat parameter can only be set to Text. Therefore, if you want to change the MessageFormat parameter from Mime to Text, you must also change the MessageBodyFormat parameter to Text.

OrganizationalUnit

Optional

Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdParameter

The OrganizationalUnit parameter specifies the organizational unit in which the new user is added (for example, redmond.contoso.com/contacts).

PrimarySmtpAddress

Optional

Microsoft.Exchange.Data.SmtpAddress

Use this parameter to specify the primary SMTP address for the mail user. By default, the primary SMTP address is generated based on the default e-mail address policy. If you specify a primary SMTP address by using this parameter, the cmdlet will set the EmailAddressPolicyEnabled attribute of the mail user to $false, and the e-mail addresses of this mail user will not be automatically updated based on e-mail address policies.

ResetPasswordOnNextLogon

Optional

System.Boolean

If the ResetPasswordOnNextLogon parameter is set to $true, the user must change the password at the next logon.

SamAccountName

Optional

System.String

The SamAccountName parameter defines the logon name used to support clients and servers running older versions of the operating system, such as Microsoft Windows NT 4.0, Windows 98, Windows 95, and LAN Manager. This attribute must contain fewer than 20 characters. An account name can contain letters, numbers, and the following punctuation marks and symbols:

  • !

  • #

  • $

  • %

  • ^

  • &

  • -

  • .

  • _

  • {

  • }

  • |

  • ~

TemplateInstance

Optional

System.Management.Automation.PSObject

When an existing object is supplied to the TemplateInstance parameter, the command will use that object's configuration to create an exact duplicate of the object on a local or target server.

UsePreferMessageFormat

Optional

System.Boolean

The UsePreferMessageFormat parameter specifies whether the message format settings configured for the mailbox will override the global settings configured for the domain. Set this parameter to $true to have the message format settings configured for the mailbox to override any global settings.

UseRusServer

Optional

System.String

noteNote:
This parameter is available only in Exchange 2007 SP2.

The UseRusServer parameter instructs the command to use the specified Mailbox server on which the Address List service is running to obtain and then set mailbox and Active Directory user attributes.

The Address List service is a component in the Exchange System Attendant service. The Address List service creates and maintains Exchange-specific attribute values in Active Directory. You can use the Address List service to update recipient objects in a domain by using specific information, such as address list membership and e-mail addresses.

WhatIf

Optional

System.Management.Automation.SwitchParameter

The WhatIf parameter instructs the command to simulate the actions that it would take on the object. By using the WhatIf parameter, you can view what changes would occur without having to apply any of those changes. You don't have to specify a value with the WhatIf parameter.

Input Types

Return Types

Errors

Error Description

 

Exceptions

Exceptions Description

 

Example

The following example consists of two commands.

In the first command, a password, $password, of the type System.Security.SecureString is created. When the command is executed, the prompt "Enter password" is displayed. The string entered by the user becomes the new password string, $password.

The second command creates a new mail-enabled user object named Ted Bremer and assigns the newly created password to the object by means of the Password parameter. Ted is an employee at Tailspin Toys, but because he works closely with employees at Contoso corporation, he is being given an e-mail address at contoso.com. Ted does not have a mailbox on the Exchange Server at Contoso. E-mail messages sent to Ted's contoso.com e-mail address is sent to his external e-mail address, ted@tailspintoys.com.

$password = Read-Host "Enter password" -AsSecureString
New-MailUser -Name "Ted Bremer" -Password $password -ExternalEmailAddress ted@tailspintoys.com -UserPrincipalName ted@contoso.com -OrganizationalUnit contoso.com