Commands › Exchange Online

Remove-StoreMailbox

Exchange Online ExchangeOnlineManagement Remove-*

Purge the mailbox and all of its message content from the mailbox database. This results in permanent data loss for the mailbox being purged. You can only run this cmdlet against disconnected or soft-deleted mailboxes. Running this command against an active mailbox fails, and you receive an error.

Quick start script

# Remove-StoreMailbox — 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-StoreMailbox
$before | Format-List

# 3. Make the change (dry run first)
Remove-StoreMailbox -Database <DatabaseIdParameter> -Identity <StoreMailboxIdParameter> -MailboxState <MailboxStateParameter> -WhatIf
Remove-StoreMailbox -Database <DatabaseIdParameter> -Identity <StoreMailboxIdParameter> -MailboxState <MailboxStateParameter>

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

Syntax

Remove-StoreMailbox -Database <DatabaseIdParameter> -Identity <StoreMailboxIdParameter> -MailboxState <MailboxStateParameter>
 [-Confirm]
 [-WhatIf]
 [<CommonParameters>]

Parameters (5)

ParameterTypeRequiredWhat it controls
-Database DatabaseIdParameter yes The Database parameter specifies the mailbox database that contains the mailbox to remove. You can use any value that uniquely identifies the database. For example:
-Identity StoreMailboxIdParameter yes The Identity parameter specifies the identity of the mailbox that you want to remove. Use the mailbox GUID as the value for this parameter.
-MailboxState MailboxStateParameter yes The MailboxState parameter specifies the mailbox state on the source mailbox database. This parameter accepts the following values:
-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.
-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.