Recover Deleted Emails in Exchange Online Using PowerShell (Get-RecoverableItems & Restore-RecoverableItems)

When an Exchange Online user permanently deletes emails using Shift + Delete or empties their Deleted Items folder, those messages are not immediately destroyed. Instead, they move into the hidden Recoverable Items mailbox subtree (Deletions and Purges), where they remain protected by the mailbox's deleted item retention window (14 days by default, configurable up to 30 days—or longer under Litigation Hold / Microsoft Purview retention policies).

With the legacy Search-Mailbox cmdlet retired, Microsoft provides two dedicated, high-speed cmdlets in the ExchangeOnlineManagement module to search and restore deleted items directly back to the user's original folder structure:

  • Get-RecoverableItems — Searches and previews deleted messages in DeletedItems and RecoverableItems.
  • Restore-RecoverableItems — Restores matching items directly back to their original folder (or Inbox/Deleted Items if the original folder was deleted).

Exchange Online Deleted Item Lifecycle Architecture

Exchange Online Recoverable Items Lifecycle & PowerShell Restoration
Stage 1: Standard Delete
Deleted Items Folder
Visible to user in Outlook & OWA
Stage 2: Shift + Delete
Recoverable Items \ Deletions
Soft-deleted retention (14–30 Days)
Stage 3: User Purge
Recoverable Items \ Purges
Hard-deleted (Admin / Hold Recovery Only)
Admin PowerShell Recovery
Get-RecoverableItems & Restore-RecoverableItems
Restores items from Deletions & Purges directly back to LastParentPath

Required RBAC Permissions

Before running Get-RecoverableItems or Restore-RecoverableItems, ensure your administrator account holds the Mailbox Import Export management role in Exchange Online (not assigned to Organization Management by default).

POWERSHELL
# Connect to Exchange Online PowerShell
Connect-ExchangeOnline -ShowBanner:$false

# Verify which Role Groups have the "Mailbox Import Export" role assigned
Get-ManagementRoleAssignment -Role "Mailbox Import Export" -GetEffectiveUsers:$false |
    Select-Object Name, RoleAssigneeName, RoleAssigneeType

Step 1: Search Deleted Emails with Get-RecoverableItems

A. Search by Subject Keyword

To search for permanently deleted emails containing a specific subject phrase inside the RecoverableItems subtree (Deletions and Purges):

POWERSHELL
Get-RecoverableItems -Identity "[email protected]" `
    -SourceFolder RecoverableItems `
    -SubjectContains "Quarterly Invoice"

Example output:

POWERSHELL
Identity             : FsNmDYNFjMRMsjyKUX78tvYAAcPBXLhGAAAAABTTPIv2KjBOhSke7IKz6G8HAMNmDYNFjMRMsjyKUX78tvYAAAAAARQA
MailboxIdentity      : [email protected]
ItemClass            : IPM.Note
Subject              : Quarterly Invoice  Q4
EntryID              : D33C8BF62A304E85291EEC82B3E86F0700C3660D83458CC44CB23C8A517EFCB6F60000000001140000
SourceFolder         : Recoverable Items\Deletions
LastParentFolderID   : C3660D83458CC44CB23C8A517EFCB6F60001C30A1A92
LastModifiedTime     : 11/06/2026 19:23:58
LastParentPath       : Finance\Invoices
OriginalFolderExists : True
IsValid              : True
Tip: Notice OriginalFolderExists : True and LastParentPath : Finance\Invoices. When OriginalFolderExists is True, Restore-RecoverableItems automatically places the email right back into Finance\Invoices.

B. Search by Date Range and Item Type

When a user accidentally deletes an entire batch of emails or calendar items on a specific day, filter by -FilterStartTime, -FilterEndTime, and -FilterItemType:

Item Type-FilterItemType Value
Email MessagesIPM.Note
Calendar Meetings / AppointmentsIPM.Appointment
ContactsIPM.Contact
TasksIPM.Task
POWERSHELL
# Find all emails deleted in the last 48 hours
Get-RecoverableItems -Identity "[email protected]" `
    -SourceFolder RecoverableItems `
    -FilterItemType IPM.Note `
    -FilterStartTime (Get-Date).AddDays(-2) `
    -FilterEndTime (Get-Date) |
    Select-Object Subject, LastModifiedTime, SourceFolder, LastParentPath, OriginalFolderExists

C. Search All Items Deleted from a Specific Folder (LastParentFolderID)

If a user accidentally purged all messages from a custom folder (e.g., TestFolder), inspect one recovered item to obtain its LastParentFolderID, then query all deleted items matching that folder ID:

POWERSHELL
# Find all items that lived inside that specific folder before deletion
Get-RecoverableItems -Identity "[email protected]" `
    -LastParentFolderID "C3660D83458CC44CB23C8A517EFCB6F60001C30A1A92"

Step 2: Restore Deleted Emails with Restore-RecoverableItems

Always preview your filter with Get-RecoverableItems first so you know exactly how many items will be restored.

A. Restore by Subject Keyword

POWERSHELL
Restore-RecoverableItems -Identity "[email protected]" `
    -SourceFolder RecoverableItems `
    -SubjectContains "Quarterly Invoice" `
    -FilterItemType IPM.Note

B. Restore All Items Deleted Within a Specific Time Window

POWERSHELL
Restore-RecoverableItems -Identity "[email protected]" `
    -SourceFolder RecoverableItems `
    -FilterItemType IPM.Note `
    -FilterStartTime "2026-11-05 08:00:00" `
    -FilterEndTime "2026-11-06 18:00:00"

C. Restore an Entire Folder's Contents via LastParentFolderID

POWERSHELL
Restore-RecoverableItems -Identity "[email protected]" `
    -LastParentFolderID "C3660D83458CC44CB23C8A517EFCB6F60001C30A1A92"

Step 3: Production Script — Export Deleted Items Inventory & Selective Restore

When a user doesn't remember the exact subject lines of the emails they deleted, run this script to export a full inventory CSV of their RecoverableItems folder, or pipe selected rows through Out-GridView -PassThru to restore only the exact items chosen.

POWERSHELL
function Invoke-ExoDeletedItemRecovery {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$MailboxIdentity,

        [Parameter(Mandatory = $false)]
        [int]$DaysBack = 14,

        [Parameter(Mandatory = $false)]
        [ValidateSet("All", "RecoverableItems", "DeletedItems", "Purges")]
        [string]$SourceFolder = "RecoverableItems",

        [Parameter(Mandatory = $false)]
        [switch]$InteractiveGridRestore
    )

    Write-Host "[*] Scanning '$SourceFolder' in '$MailboxIdentity' (Last $DaysBack days)..." -ForegroundColor Cyan

    $Params = @{
        Identity        = $MailboxIdentity
        FilterStartTime = (Get-Date).AddDays($DaysBack)
        FilterEndTime   = (Get-Date)
    }
    if ($SourceFolder -ne "All") {
        $Params["SourceFolder"] = $SourceFolder
    }

    $Items = Get-RecoverableItems @Params

    if (-not $Items) {
        Write-Warning "No recoverable items found in '$MailboxIdentity' for the last $DaysBack days."
        return
    }

    Write-Host "[+] Found $($Items.Count) recoverable items." -ForegroundColor Green

    if ($InteractiveGridRestore) {
        $Selected = $Items | Select-Object Subject, ItemClass, LastModifiedTime, SourceFolder, LastParentPath, OriginalFolderExists, EntryID |
            Out-GridView -Title "Select Deleted Items to Restore for $MailboxIdentity" -PassThru

        foreach ($Item in $Selected) {
            Write-Host "[>] Restoring: $($Item.Subject) ($($Item.EntryID))..." -ForegroundColor Yellow
            Restore-RecoverableItems -Identity $MailboxIdentity -EntryID $Item.EntryID
        }
        Write-Host "[+] Selected items restored successfully!" -ForegroundColor Green
    } else {
        $CsvPath = ".\RecoverableItems_$($MailboxIdentity -replace '@.*','')_$(Get-Date -Format 'yyyyMMdd_HHmm').csv"
        $Items | Select-Object Subject, ItemClass, LastModifiedTime, SourceFolder, LastParentPath, OriginalFolderExists, EntryID, LastParentFolderID |
            Export-Csv -Path $CsvPath -NoTypeInformation -Encoding UTF8
        Write-Host "[+] Inventory exported to: $CsvPath" -ForegroundColor Green
    }
}

# Example 1: Export CSV inventory for the user to review
# Invoke-ExoDeletedItemRecovery -MailboxIdentity "[email protected]" -DaysBack 14

# Example 2: Pick exact emails in an interactive GridView and restore them immediately
# Invoke-ExoDeletedItemRecovery -MailboxIdentity "[email protected]" -DaysBack 7 -InteractiveGridRestore