Skip to content

Instantly share code, notes, and snippets.

@Spartan-196
Last active July 26, 2021 19:41
Show Gist options
  • Save Spartan-196/249b097f099426ad67b4000b96e32a2f to your computer and use it in GitHub Desktop.
Save Spartan-196/249b097f099426ad67b4000b96e32a2f to your computer and use it in GitHub Desktop.
Restore Mailbox request and get stats

From time to time you must fix a GUID or ImmutableID issue when migrating between AD domains, Tenants, and or federating services. When this happens and you end up with a soft delted mailbox for a specific user and you wish to restore it to their new mailbox you can initate a restore request in O365

$Alias = "<mailbox alias>"
$OldMailbox = Get-Mailbox -SoftDeletedMailbox  -Identity $alias | Select-Object Name,Alias,ExchangeGuid,ExternalDirectoryObjectID,LagacyExchangeDN
$NewMailbox = Get-Mailbox -Identity $alias | Select Name,Alias,ExchangeGUID,ExtenralDirectoryObjectID,LegacyExchangeDN
New-MailboxRestoreRequest -SourceMailbox $OldMailbox.ExchangeGuid.toString() -TargetMailbox $NewMailbox.ExchangeGUID.toString() -AllowLegacyDNMismatch

Get Status of all InProgress requests

Get-MailboxRestoreRequest -Status InProgress| Select Name,TargetMailbox,Status,RequestGuid | ForEach-Object {Get-MailboxRestoreRequestStatistics -Identity $_.RequestGuid | Select Name,StatusDetail,TargetAlias,EstimatedTransferSize,BytesTransferred,BytesTransferredPerMinute,PercentComplete }

Select Status of specific restore

Get-MailboxRestoreRequest | Select Name,TargetMailbox,Status,RequestGuid | Out-GridView -Title "Restore Request List" –PassThru | ForEach-Object {Get-MailboxRestoreRequestStatistics -Identity $_.RequestGuid | Select Name,StatusDetail,TargetAlias,EstimatedTransferSize,BytesTransferred,BytesTransferredPerMinute,PercentComplete }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment