New-MailUser (RTM)
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
Use the New-MailUser cmdlet to create a new mail-enabled user.
Syntax
New-MailUser -Name <String> -ExternalEmailAddress <ProxyAddress> -OrganizationalUnit <OrganizationalUnitIdParameter> -Password <SecureString> -UserPrincipalName <String> [-Alias <String>] [-DisplayName <String>] [-DomainController <Fqdn>] [-FirstName <String>] [-Initials <String>] [-LastName <String>] [-MacAttachmentFormat <BinHex | UuEncode | AppleSingle | AppleDouble>] [-MessageBodyFormat <Text | Html | TextAndHtml>] [-MessageFormat <Text | Mime>] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName <String>] [-TemplateInstance <PSObject>] [-UsePreferMessageFormat <$true | $false>]
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. |
OrganizationalUnit |
Required |
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). |
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:
|
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:
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:
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:
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. |
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. |
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