Export all mailboxes to individual .pst powershell

Maintain control of your Microsoft Office 365 email data

Export all mailboxes to individual .pst powershell

Veeam Logoby GTL » Thu Apr 05, 2018 4:54 pm

Hi everyone!! I have called veeam support and was told they cannot help me with these powershell commands.

I am testing exporting all backed up mailboxes to individual psts. I am aware that there is no GUI function to do so. You can only export individually.

However, i found these veeam instructions:

https://helpcenter.veeam.com/docs/vbo36 ... tml?ver=15
Example 2 will allow me to whip up a .bat file that will kick off a full export to pst for individual mailboxes, but i can't get past line 2:

1) $session = Get-VBOExchangeItemRestoreSession
this works fine
2) $database = Get-VEXDatabase -Session $session
gives me this error message:

Code: Select all
Get-VEXDatabase : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At line:1 char:38
+ $database = Get-VEXDatabase -Session $session
+                                      ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-VEXDatabase], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Exchange.PowerShell.Cmdlets.Items.GetVEXDatabase



Any ideas? I dont really get that far and it already comes back with an error.

Thank you!
GTL
Novice
 
Posts: 4
Liked: never
Joined: Thu Apr 05, 2018 4:47 pm
Full Name: GL

Re: Export all mailboxes to individual .pst powershell

Veeam Logoby v.Eremin » Thu Apr 05, 2018 5:34 pm

Is there a running restore session? Does a session variable return anything? Thanks.
v.Eremin
Veeam Software
 
Posts: 14722
Liked: 1102 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Export all mailboxes to individual .pst powershell

Veeam Logoby GTL » Thu Apr 05, 2018 7:58 pm

I have found the answer, run the following commands from a powershell that has been "right click" run as administrator.

$organization = Get-VBOOrganization -Name "ThisIsTheOrganizationNameThatShowsUpUnderOrganizations"
Start-VBOExchangeItemRestoreSession -LatestState -Organization $organization
$session = Get-VBOExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session

Now this part has the export

$mailbox = Get-VEXMailbox -Database $database -Name "ThisIsTheMailboxDisplayName"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\NameOfThePSTFile.pst"

I whipped up some notepad and excel magic and created the following .ps1 file (its a .bat file that you run in powershell using .\filenameyouused.ps1)

As an example, here are the contents of the .ps1 file i created


$organization = Get-VBOOrganization -Name "BlahBlahBlah.onmicrosoft.com"
Start-VBOExchangeItemRestoreSession -LatestState -Organization $organization
$session = Get-VBOExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session
$mailbox = Get-VEXMailbox -Database $database -Name "AC Forms"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\AC Forms.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Accounts Payable - Email"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Accounts Payable - Email.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Accounts Receivable"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Accounts Receivable.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Admin"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Admin.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Annie Herrera"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Annie Herrera.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Angela Arme"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Angela Arme.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Anne Flam"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Anne Flam.pst"
$mailbox = Get-VEXMailbox -Database $database -Name "Anthony Buinn"
Export-VEXItem -Mailbox $mailbox -To "E:\Office365 Backups\Full PST Export\Anthony Buinn.pst"


etc etc etc
you get the idea

Here are the links i figured it out from:
https://helpcenter.veeam.com/docs/vbo36 ... tml?ver=15
(i used example2)
and
https://helpcenter.veeam.com/docs/vbo36 ... tml?ver=15
GTL
Novice
 
Posts: 4
Liked: never
Joined: Thu Apr 05, 2018 4:47 pm
Full Name: GL

Re: Export all mailboxes to individual .pst powershell

Veeam Logoby GTL » Thu Apr 05, 2018 9:29 pm

NOTE!

I have noticed some failures during the export but was unable to see which mailbox it failed on because the error message were to long and got chopped off.

I have tried adding -ResultSize Unlimited but it seems the Export-VexItem command doesnt recognize it.

I suggest changing your export directory to something very very short so you can read which mailbox failed. Example: E:\V\Blahblah.pst
GTL
Novice
 
Posts: 4
Liked: never
Joined: Thu Apr 05, 2018 4:47 pm
Full Name: GL


Return to Veeam Backup for Microsoft Office 365



Who is online

Users browsing this forum: No registered users and 2 guests