Skip to main content
Get mailbox
Updated over a week ago

Command

Get-Mailbox

Description

The command to get mailboxes from a Microsoft 365 environment.

Note: The Microsoft Exchange Online PowerShell module also has a Get-Mailbox command that could cause conflicts. You can avoid this problem by using module-qualified names in your scripts. For the ShareGate PowerShell module, a module-qualified name would look like this: sharegate\Get-Mailbox.

Examples

Getting a mailbox by ID

$connection = Connect-MicrosoftOnline $mailboxId = "0bc4c795-fc91-4920-b6dd-bb33c4e2e6cd" Get-Mailbox -Id $mailboxId -Connection $connection

Getting multiple mailboxes by IDs

$connection = Connect-MicrosoftOnline $mailboxIds = "0bc4c795-fc91-4920-b6dd-bb33c4e2e6cd", "bdbfe982-e04c-4387-ad27-207db15e8734" Get-Mailbox -Id $mailboxIds -Connection $connection -AllowMultiple

Getting all shared mailboxes

$connection = Connect-MicrosoftOnline Get-Mailbox -MailboxType Shared -Connection $connection -AllowMultiple

Getting a mailbox by name

$connection = Connect-MicrosoftOnline $mailboxName = "Adele Vance" Get-Mailbox -Name $mailboxName -Connection $connection

Getting a mailbox by email address

$connection = Connect-MicrosoftOnline $mailboxEmail = "[email protected]" Get-Mailbox -EmailAddress $mailboxEmail -Connection $connection

Syntax

Get-Mailbox
-Connection <Connection>
[-MailboxType <MailboxType[]>]
[-AllowMultiple]
Get-Mailbox
-Name <String[]>
-Connection <Connection>
[-MailboxType <MailboxType[]>]
[-AllowMultiple]
Get-Mailbox
-Id <String[]>
-Connection <Connection>
[-MailboxType <MailboxType[]>]
[-AllowMultiple]
Get-Mailbox
-EmailAddress <String[]>
-Connection <Connection>
[-MailboxType <MailboxType[]>]
[-AllowMultiple]

Parameters

-AllowMultiple <SwitchParameter>

Specifies that multiple mailboxes can be returned by the command.

Required?

False

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Connection <Connection>

Specifies the connection.

Required?

True

Default value

None

Accept pipeline input?

True (ByValue)

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-EmailAddress <String[]>

Specifies the email address of the mailbox (wildcards supported).

Required?

True

Default value

System.String[]

Accept pipeline input?

False

Accept wildcard characters?

True

Parameter set name

EmailAddress

Aliases

None

-Id <String[]>

Specifies the id of the mailbox.

Required?

True

Default value

System.String[]

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

Id

Aliases

None

-MailboxType <MailboxType[]>

Specifies the type of the mailbox.

Required?

False

Default value

ShareGate.Mailboxes.Copy.Plugin.Automation.Mailboxes.Entities.MailboxType[]

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Name <String[]>

Specifies the display name of the mailbox (wildcards supported).

Required?

True

Default value

System.String[]

Accept pipeline input?

False

Accept wildcard characters?

True

Parameter set name

Name

Aliases

None

Did this answer your question?