Maintain control of your Microsoft Office 365 data
Post Reply
GTL
Novice
Posts: 4
Liked: 1 time
Joined: Apr 05, 2018 4:47 pm
Full Name: GL
Contact:

Export all mailboxes to individual .pst powershell

Post by GTL »

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!

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by veremin »

Is there a running restore session? Does a session variable return anything? Thanks.

GTL
Novice
Posts: 4
Liked: 1 time
Joined: Apr 05, 2018 4:47 pm
Full Name: GL
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by GTL » 1 person likes this post

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: 1 time
Joined: Apr 05, 2018 4:47 pm
Full Name: GL
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by GTL »

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

jedduff
Novice
Posts: 3
Liked: 2 times
Joined: Jan 05, 2017 1:55 pm
Full Name: Jeremie Dufault
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by jedduff » 2 people like this post

Hi! I use your script, but I created a csv file with a ForEach to extract the pst file.

This is the script I made

$mailbox = Get-VEXMailbox -Database $database -Name "YOURORGANIZATIONNAME"
$users = Import-Csv c:\temp\users.csv
ForEach ($user in $users) {
$mailbox = Get-VEXMailbox -Database $database -Name "$($user.accountname)"
Export-VEXItem -Mailbox $mailbox -To "d:\pst\$($user.accountname).pst"
}

Image

Symbiot78
Influencer
Posts: 10
Liked: never
Joined: Mar 27, 2019 8:24 am
Full Name: Martin Rask Thomsen
Contact:

[MERGED]periodic export to <some drive option> ?

Post by Symbiot78 »

Hi

my org has a requirement to export all mailboxes to an external drive for safekeeping offline. Say.. monthly.. or quarterly.

anyway I can achieve this in the veeam console? or is there a scripting option?

Egor Yakovlev
Veeam Software
Posts: 1409
Liked: 323 times
Joined: Jun 14, 2013 9:30 am
Full Name: Egor Yakovlev
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by Egor Yakovlev »

Hi Martin,
Merged your post with existing thread. Check answers above.
Scripted Export-VEXItem should do the trick.
/Cheers!

Symbiot78
Influencer
Posts: 10
Liked: never
Joined: Mar 27, 2019 8:24 am
Full Name: Martin Rask Thomsen
Contact:

Re: Export all mailboxes to individual .pst powershell

Post by Symbiot78 »

Hi

Thx for the merge.

I've created the following script based on content in this thread:

Code: Select all

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




$mailboxes = Get-VEXMailbox -Database $database

foreach ($user in $mailboxes)
{

$mailbox = Get-VEXMailbox -Database $database -name $user
Export-VEXItem -Mailbox $mailbox -To "Z:\test_export\$($user.Email).pst"
}


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest