Maintain control of your Microsoft 365 data
Post Reply
ereynolds
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2020 1:14 am
Full Name: Edward Reynolds
Contact:

Restore entire o365 mailbox using powershell.

Post by ereynolds »

Looking to automate the restoration of a mailbox via Veeam Backup for Microsoft Office 365.

In my test case I would like to restore mailbox "A" to mailbox "B"
I attempted to use Restore-VEXItem, but get errors...

Import-Module Veeam.Exchange.PowerShell

$org = Get-VBOOrganization -Name "O365Org"

$sourceUser = Get-VBOOrganizationUser -Organization $org -UserName "a@domain.com"
$targetUser = Get-VBOOrganizationUser -Organization $org -UserName "b@domain.com"

Restore-VEXItem -Mailbox $sourceUser -TargetMailbox $targetUser

Error:

Restore-VEXItem : Cannot bind parameter 'Mailbox'. Cannot convert the "Veeam.Archiver.PowerShell.Model.VBOOrganizationUser" value of type
"Veeam.Archiver.PowerShell.Model.VBOOrganizationUser" to type "Veeam.Exchange.PowerShell.Model.Items.VEXMailbox".
At line:1 char:26
+ Restore-VEXItem -Mailbox $sourceUser -TargetMailbox $targetUser
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Restore-VEXItem], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Exchange.PowerShell.Cmdlets.Restore.RestoreVEXItem


Any suggestions would be great.
Cheers!
Ed.
Polina
Veeam Software
Posts: 2972
Liked: 705 times
Joined: Oct 21, 2011 11:22 am
Full Name: Polina Vasileva
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by Polina »

Hi Ed,

For restore, you need to start a restore session and get the mailbox from your VBO backup database (while you're getting a user from an organization added to the VBO scope).
nielsengelen
Product Manager
Posts: 5635
Liked: 1181 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by nielsengelen »

To get you started:

Code: Select all

Import-Module "Veeam.Archiver.PowerShell.psd1"
Import-Module "Veeam.Exchange.PowerShell"

$session = Start-VBOExchangeItemRestoreSession -LatestState
$database = Get-VEXDatabase -Session $session
$mailbox = Get-VEXMailbox -Database $database
$mailbox will contain every mailbox then and u can continue with Restore-VEXItem to perform the actual restore from there.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
ereynolds
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2020 1:14 am
Full Name: Edward Reynolds
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by ereynolds »

Thank you!
Appreciate the help!

In regards to archive mailboxes, I can select the user "A" archive as the source by using:
$mailbox = Get-VEXMailbox -Database $database -Name "In-Place Archive - A"

But how can I select the target destination of user "B" Archive?
Restore-VEXItem -Mailbox $mailbox -TargetMailbox b@domain.com -RestoreChangedItem -Credential $Cred

Kind Regards,
Ed.
ereynolds
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2020 1:14 am
Full Name: Edward Reynolds
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by ereynolds »

I think the answer is I can't restore direct to a users Archive, as it's not directly accessible.
Instead I believe I would need to restore the data to the users mailbox and apply archive policy.

Kind Regards,
Ed.
nielsengelen
Product Manager
Posts: 5635
Liked: 1181 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by nielsengelen »

Correct, restore to the archive is not possible.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
ereynolds
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2020 1:14 am
Full Name: Edward Reynolds
Contact:

Re: Restore entire o365 mailbox using powershell.

Post by ereynolds »

Thank you for your assistance!
Very much appreciated!!

Kind Regards,
Ed.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests