Commands › Exchange Online

New-MailUser

Exchange Online ExchangeOnlineManagement New-*

Create mail users. Mail users (also known as mail-enabled users) have email addresses and accounts in the Exchange organization, but they don't have Exchange mailboxes. Email messages sent to mail users are delivered to the specified external email address.

Quick start script

# New-MailUser — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-ExchangeOnline -CertificateThumbprint $thumb -AppId $appId -Organization $org

# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-MailUser
$before | Format-List

# 3. Make the change (dry run first)
New-MailUser -Name <String> -ExternalEmailAddress <ProxyAddress> -FederatedIdentity <String> -WhatIf
New-MailUser -Name <String> -ExternalEmailAddress <ProxyAddress> -FederatedIdentity <String>

# 4. Verify and diff
$after = Get-MailUser
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax — 7 parameter sets

DisabledUser

New-MailUser [-Name] <String> -ExternalEmailAddress <ProxyAddress>
 [-Alias <String>]
 [-ArbitrationMailbox <MailboxIdParameter>]
 [-Confirm]
 [-DisplayName <String>]
 [-DomainController <Fqdn>]
 [-FirstName <String>]
 [-ImmutableId <String>]
 [-Initials <String>]
 [-LastName <String>]
 [-MacAttachmentFormat <MacAttachmentFormat>]
 [-MailboxRegion <String>]
 [-MessageBodyFormat <MessageBodyFormat>]
 [-MessageFormat <MessageFormat>]
 [-ModeratedBy <MultiValuedProperty>]
 [-ModerationEnabled <Boolean>]
 [-OrganizationalUnit <OrganizationalUnitIdParameter>]
 [-PrimarySmtpAddress <SmtpAddress>]
 [-RemotePowerShellEnabled <Boolean>]
 [-ResetPasswordOnNextLogon <Boolean>]
 [-SamAccountName <String>]
 [-SendModerationNotifications <TransportModerationNotificationFlags>]
 [-UsePreferMessageFormat <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

EnabledUser

New-MailUser [-Name] <String> -ExternalEmailAddress <ProxyAddress> -Password <SecureString> -UserPrincipalName <String>
 [-Alias <String>]
 [-ArbitrationMailbox <MailboxIdParameter>]
 [-Confirm]
 [-DisplayName <String>]
 [-DomainController <Fqdn>]
 [-FirstName <String>]
 [-ImmutableId <String>]
 [-Initials <String>]
 [-LastName <String>]
 [-MacAttachmentFormat <MacAttachmentFormat>]
 [-MailboxRegion <String>]
 [-MessageBodyFormat <MessageBodyFormat>]
 [-MessageFormat <MessageFormat>]
 [-ModeratedBy <MultiValuedProperty>]
 [-ModerationEnabled <Boolean>]
 [-OrganizationalUnit <OrganizationalUnitIdParameter>]
 [-PrimarySmtpAddress <SmtpAddress>]
 [-RemotePowerShellEnabled <Boolean>]
 [-ResetPasswordOnNextLogon <Boolean>]
 [-SamAccountName <String>]
 [-SendModerationNotifications <TransportModerationNotificationFlags>]
 [-UsePreferMessageFormat <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

EnableRoomMailboxAccount

New-MailUser [-Name] <String> [-MicrosoftOnlineServicesID <WindowsLiveId>]
 [-Alias <String>]
 [-Confirm]
 [-DisplayName <String>]
 [-FirstName <String>]
 [-ImmutableId <String>]
 [-Initials <String>]
 [-LastName <String>]
 [-MailboxRegion <String>]
 [-ModeratedBy <MultiValuedProperty>]
 [-ModerationEnabled <Boolean>]
 [-OrganizationalUnit <OrganizationalUnitIdParameter>]
 [-PrimarySmtpAddress <SmtpAddress>]
 [-RemotePowerShellEnabled <Boolean>]
 [-SendModerationNotifications <TransportModerationNotificationFlags>]
 [-WhatIf]
 [<CommonParameters>]

FederatedUser

New-MailUser [-Name] <String> -FederatedIdentity <String>
 [-ExternalEmailAddress <ProxyAddress>]
 [-Alias <String>]
 [-ArbitrationMailbox <MailboxIdParameter>]
 [-Confirm]
 [-DisplayName <String>]
 [-DomainController <Fqdn>]
 [-FirstName <String>]
 [-ImmutableId <String>]
 [-Initials <String>]
 [-LastName <String>]
 [-MailboxRegion <String>]
 [-ModeratedBy <MultiValuedProperty>]
 [-ModerationEnabled <Boolean>]
 [-OrganizationalUnit <OrganizationalUnitIdParameter>]
 [-PrimarySmtpAddress <SmtpAddress>]
 [-RemotePowerShellEnabled <Boolean>]
 [-ResetPasswordOnNextLogon <Boolean>]
 [-SamAccountName <String>]
 [-SendModerationNotifications <TransportModerationNotificationFlags>]
 [-WhatIf]
 [<CommonParameters>]

3 more parameter sets — see the parameter table below.

Parameters (30)

ParameterTypeRequiredWhat it controls
-Name String yes The Name parameter specifies the unique name of the mail user. The maximum length is 64 characters. If the value contains spaces, enclose the value in quotation marks (").
-ExternalEmailAddress ProxyAddress yes The ExternalEmailAddress parameter specifies the target email address of the mail contact or mail user. By default, this value is used as the primary email address of the mail contact or mail user.
-FederatedIdentity String yes This parameter is available only in the cloud-based service.
-MicrosoftOnlineServicesID WindowsLiveId yes The MicrosoftOnlineServicesID parameter specifies the user ID for the object. This parameter only applies to objects in the cloud-based service. It isn't available for on-premises deployments.
-Password SecureString yes The Password parameter specifies the password for the user's account.
-UserPrincipalName String yes This parameter is available only in on-premises Exchange.
-Alias String The Alias parameter specifies the Exchange alias (also known as the mail nickname) for the recipient. This value identifies the recipient as a mail-enabled object, and shouldn't be confused with multiple email...
-ArbitrationMailbox MailboxIdParameter This parameter is available only in on-premises Exchange.
-Confirm SwitchParameter The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on whether the cmdlet requires confirmation before proceeding.
-DisplayName String The DisplayName parameter specifies the display name of the mail user. The display name is visible in the Exchange admin center, in address lists, and in Outlook. The maximum length is 256 characters. If the value...
-DomainController Fqdn This parameter is available only in on-premises Exchange.
-FirstName String The FirstName parameter specifies the user's first name.
-ImmutableId String The ImmutableId parameter is used by GAL synchronization (GALSync) and specifies a unique and immutable identifier in the form of an SMTP address for an Exchange mailbox used for federated delegation when requesting...
-Initials String The Initials parameter specifies the user's middle initials.
-LastName String The LastName parameter specifies the user's last name.
-HVEAccount SwitchParameter This parameter is available only in the cloud-based service.
-MacAttachmentFormat MacAttachmentFormat The MacAttachmentFormat parameter specifies the Apple Macintosh operating system attachment format to use for messages sent to the mail contact or mail user. Valid values are:
-MailboxRegion String This parameter is available only in the cloud-based service
-MessageBodyFormat MessageBodyFormat The MessageBodyFormat parameter specifies the message body format for messages sent to the mail contact or mail user. Valid values are:
-MessageFormat MessageFormat The MessageFormat parameter specifies the message format for messages sent to the mail contact or mail user. Valid values are:
-ModeratedBy MultiValuedProperty The ModeratedBy parameter specifies one or more moderators for this recipient. A moderator approves messages sent to the recipient before the messages are delivered. A moderator must be a mailbox, mail user, or mail...
-ModerationEnabled Boolean The ModerationEnabled parameter specifies whether moderation is enabled for this recipient. Valid value are:
-OrganizationalUnit OrganizationalUnitIdParameter The OrganizationalUnit parameter specifies the location in Active Directory where the new mail user is created.
-PrimarySmtpAddress SmtpAddress This parameter is functional only in on-premises Exchange.
-RemotePowerShellEnabled Boolean The RemotePowerShellEnabled parameter specifies whether the user has access to Exchange PowerShell. Valid values are:
-ResetPasswordOnNextLogon Boolean This parameter is available only in on-premises Exchange.
-SamAccountName String This parameter is available only in on-premises Exchange.
-SendModerationNotifications TransportModerationNotificationFlags The SendModerationNotifications parameter specifies when moderation notification messages are sent. Valid values are:
-UsePreferMessageFormat Boolean The UsePreferMessageFormat specifies whether the message format settings configured for the mail user or mail contact override the global settings configured for the remote domain or configured by the message sender....
-WhatIf SwitchParameter The WhatIf switch shows what the command does without making any changes. You don't need to specify a value with this switch.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.