- Start Windows PowerShell
Start > search for "PowerShell" > Start Windows PowerShell by clicking on "Run as Administrator".
- Connect the Windows PowerShell to Office 365 Exchange Online . Please execute below command in PowerShell.
$LiveCred = Get-Credential
(Supply Exchange Online Admin’s log in credentials in the prompt window)Set-ExecutionPolicy Unrestricted
(Proceed with Y if prompted)$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
https://ps.outlook.com/powershell/
-Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
- Verify if the old mailbox is in deleted state.
Get-Mailbox -SoftDeletedMailbox accounts
- If the Mailbox is found collect the ExchangeGuid of the deleted Mailbox.
(Get-Mailbox -SoftDeletedMailbox
Deleted_User_Alias@domain.com).ExchangeGuid
- Collect the ExchangeGuid of the Active Mailbox.
(Get-Mailbox
ACTIVE_USER_ALIAS@domain.com).ExchangeGuid
- Now copy the data from the deleted mailbox to the new Mailbox.
New-MailboxRestoreRequest -SourceMailbox "Guid of Deleted Mailbox copied from step 4" -TargetMailbox "Guid of Deleted Mailbox copied from step 5" -AllowLegacyDNMismatch -verbose
- Monitor the same.
Get-MailboxRestoreRequest
- Once it is completed all the data would be moved to the new one.
Sample with Regular PowerShell
1) Verify the active Mailbox.
Get-Mailbox ACTIVE_USER_ALIAS | FL Name,Alias,UserPrincipalName,ExchangeGuid,Guid,EmailAddresses,Database
2) Verified the same in the soft deleted list.
Get-Mailbox -SoftDeletedMailbox Deleted_User_Alias | FL Name,Alias,UserPrincipalName,ExchangeGuid,Guid,EmailAddresses,Database
3) Collect the data about the mailboxes.
Active Mailbox.
Get-Mailbox ACTIVE_USER_ALIAS | FL Name,Alias,UserPrincipalName,ExchangeGuid,Guid,EmailAddresses,Database
Name : ACTIVE_USER_ALIAS
Alias : ACTIVE_USER_ALIAS
UserPrincipalName : ACTIVE_USER_ALIAS@domain.com
ExchangeGuid : b09181cd-9183-4036-8946-9339dfa27702
Guid : 28101858-670e-4b47-aedc-7f9cc583a80dEmailAddresses : {SIP:ACTIVE_USER_ALIAS@domain.com, SMTP:ACTIVE_USER_ALIAS@domain.com, smtp:ACTIVE_USER_ALIAS@domain.com}
Deleted Mailbox.
Get-Mailbox -SoftDeletedMailbox Deleted_User_Alias | FL
Name,Alias,UserPrincipalName,ExchangeGuid,Guid,EmailAddresses,Database
Name : Deleted_User_Alias
Alias : Deleted_User_Alias
UserPrincipalName : Deleted_User_Alias@domain.com
ExchangeGuid : b4dc2e0c-d2ba-4524-9722-dd279b6c6f61
Guid : a3d02e59-60fd-4bca-b9ca-609c2f792891
EmailAddresses : {SIP:ecbb89072dda4219a644fab1b054efa6;Deleted_User_Alias@domain.com}
Creating the Mailbox restore request.
New-MailboxRestoreRequest -SourceMailbox b4dc2e0c-d2ba-4524-9722-dd279b6c6f61 -TargetMailbox b09181cd-9183-4036-8946-9339dfa27702 -AllowLegacyDNMismatch -Verbose
Once Request created successfully confirmed the batch completed successfully.
Get-MailboxRestoreRequest | FL Identity,requestguid,Status
Sample with GUI with the help of ISE PowerShell
- Start the “Windows PowerShell ISE”, connect it to Exchange Online and Execute below commands.
- This would show the list of SoftDeletedMaiboxes, please select one in question and click OK (@ Bottom).
$DeletedMailbox = Get-Mailbox -SoftDeletedMailbox | Select DisplayName,ExchangeGuid,PrimarySmtpAddress,ArchiveStatus,DistinguishedName | Out-GridView -Title " This is the list of SoftDeletedMaiboxes, please select one." -PassThru
- Select the Target Mailbox to which the data needs to be moved.
-
$MergeMailboxTo = Get-Mailbox | Select Name,PrimarySmtpAddress,DistinguishedName | Out-GridView -Title " Select the Target Mailbox to which the data needs to be moved." –PassThru
- Run the Merge Command
New-MailboxRestoreRequest -SourceMailbox $DeletedMailbox.DistinguishedName -TargetMailbox $MergeMailboxTo.PrimarySmtpAddress –AllowLegacyDNMismatch
-
- View the progress
- Grab the restore ID for the one you want progress on.
$RestoreProgress = Get-MailboxRestoreRequest | Select Name,TargetMailbox,Status,RequestGuid | Out-GridView -Title "Restore Request List" –PassThru
- Get the progress in Percent complete.
Get-MailboxRestoreRequestStatistics -Identity $RestoreProgress.RequestGuid | Select Name,StatusDetail,TargetAlias,PercentComplete