A user has unintentionally deleted objects in Outlook. This can be e-mails or even meetings. The bad news is that the user can no longer access these objects. The good news: We can restore these objects with PowerShell. This is exactly what I will show in this post.
Prerequisites
First of all, you need to check if you have assigned the Import-Export role. This is not the case even with the global administrator. It is essential to check this.
In the Admin Center, navigate to Roles – Exchange – Mailbox Import Export. Now assign the role to your user.
Next, we install – if necessary – the Exchange Online module.
Install-Module ExchangeOnlineManagement -Force -AllowClobber
Login now.
Connect-ExchangeOnline
I would definitely recommend checking the role assignment with this command!
Get-ManagementRole -Cmdlet Restore-RecoverableItems
You should get an output. If not, then back to the start, the role assignment must be done without fail.
Recovering Deleted Outlook Objects
In this section you will find examples of how to restore items. You can build on these examples.
Specify Start- and EndTime
Get-RecoverableItems -Identity f.bizeps@sid-500.com `
-FilterStartTime "1/2/2023 12:00:00 AM" `
-FilterEndTime "28/2/2023 11:59:59 PM" |
Restore-RecoverableItems -Verbose
Retrieve and Restore Calendar Items only
Get-RecoverableItems -Identity f.bizeps@sid-500.com |
Where-Object LastParentPath -eq 'Kalender' |
Restore-RecoverableItems -Verbose
A combination of the examples shown above
Get-RecoverableItems -Identity f.bizeps@sid-500.com `
-FilterStartTime "1/2/2023 12:00:00 AM" `
-FilterEndTime "28/2/2023 11:59:59 PM" |
Where-Object LastParentPath -eq 'Kalender' | Restore-RecoverableItems -Verbose
I hope you found what you were looking for. See you next time!
Categories: Microsoft 365, PowerShell