-
- Lurker
- Posts: 1
- Liked: never
- Joined: May 18, 2020 11:03 am
- Full Name: Cicada
- Contact:
Export to .pst multiple mailboxes
Hi everyone!
I try to export multiple mailboxes with PowerShell.
I can use and export a mailbox https://helpcenter.veeam.com/docs/backu ... office-365 (use Example 7)
But I want to export 100 from 1000, using .csv list. Maybe someone came across such a task and has a ready-made solution?
Thank you!
I try to export multiple mailboxes with PowerShell.
I can use and export a mailbox https://helpcenter.veeam.com/docs/backu ... office-365 (use Example 7)
But I want to export 100 from 1000, using .csv list. Maybe someone came across such a task and has a ready-made solution?
Thank you!
-
- Product Manager
- Posts: 9848
- Liked: 2607 times
- Joined: May 13, 2017 4:51 pm
- Full Name: Fabian K.
- Location: Switzerland
- Contact:
Re: Export to .pst multiple mailboxes
You need to:
1) Start the restore Session
2) Import the csv File
3) loop through each mailbox in the file and start the pst export command
The necessary code could be something like that (cannot test it at the moment, I don‘t have access to my vbo server)
1) Start the restore Session
2) Import the csv File
3) loop through each mailbox in the file and start the pst export command
The necessary code could be something like that (cannot test it at the moment, I don‘t have access to my vbo server)
Code: Select all
# Starting Restore Session with latest Restore Point
$organization = Get-VBOOrganization -Name "Your Org Name"
Start-VBOExchangeItemRestoreSession -LatestState -Organization $organization
# Starting the PST Export for all users in the csv
$session = Get-VBOExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session -Name "YourM365TenantName.onmicrosoft.com"
$Mailboxes = Import-Csv C:\temp\mailboxes.csv
# Loop through each mailbox from your csv file.
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name
Export-VEXItem -Mailbox $user -To "C:\Export\$($mailbox.name).pst"
}
Product Management Analyst @ Veeam Software
-
- Service Provider
- Posts: 34
- Liked: 4 times
- Joined: Nov 03, 2016 10:56 am
- Contact:
[Merged] Script to export multiple mailboxes to PSt
Hi,
I'm trying to export multiple Mailboxes to PST with powershell. The problem is, that only the first Mailbox in the CSV get's exported, on the second Powershell reports that there's no value for $user.
any ideas appreciated.
best regards
I'm trying to export multiple Mailboxes to PST with powershell. The problem is, that only the first Mailbox in the CSV get's exported, on the second Powershell reports that there's no value for $user.
Code: Select all
$organization = get-vboorganization -name *<organizationname>*
$restorepoint = Get-VBORestorePoint -Organization $organization | Select-Object -Last 1
Start-VBOExchangeItemRestoreSession -restorepoint $restorepoint -Organization $organization
$session = Get-VBOExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session -Name *<organizationname>*
$mailboxes = Import-Csv C:\temp\mailboxusers.csv
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name}
Export-VEXItem -Mailbox $user -To "D:\Export\Mail\$($mailbox.name).pst"
}
any ideas appreciated.
best regards
-
- Product Manager
- Posts: 9848
- Liked: 2607 times
- Joined: May 13, 2017 4:51 pm
- Full Name: Fabian K.
- Location: Switzerland
- Contact:
Re: Export to .pst multiple mailboxes
Hello Lukas
I moved your question to this topic.
It look like you are closing the loop before you export any data.
The } after $mailbox.name seems wrong to me.
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name}
Export-VEXItem -Mailbox $user -To "D:\Export\Mail\$($mailbox.name).pst"
}
The loop should loop like this:
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name
Export-VEXItem -Mailbox $user -To "D:\Export\Mail\$($mailbox.name).pst"
}
Please try my sample script from my answer above.
Best,
Fabian
I moved your question to this topic.
It look like you are closing the loop before you export any data.
The } after $mailbox.name seems wrong to me.
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name}
Export-VEXItem -Mailbox $user -To "D:\Export\Mail\$($mailbox.name).pst"
}
The loop should loop like this:
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name
Export-VEXItem -Mailbox $user -To "D:\Export\Mail\$($mailbox.name).pst"
}
Please try my sample script from my answer above.
Best,
Fabian
Product Management Analyst @ Veeam Software
-
- Service Provider
- Posts: 34
- Liked: 4 times
- Joined: Nov 03, 2016 10:56 am
- Contact:
Re: Export to .pst multiple mailboxes
Hi Fabian,
in the end it was a typo in the csv-file, now it works.
Thank you
in the end it was a typo in the csv-file, now it works.
Thank you
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Jul 26, 2023 12:34 pm
- Contact:
Re: Export to .pst multiple mailboxes
Hello,
we are using Veeam Backup & Replication 12 with Exchange 2016 on prem.
We are planning to export all Mailboxes into single PST files to import them into Exchange Online.
Exporting a single Usermailbox with the following code is working well.
I used the script posted here to export multiple Usermailboxes into PST files but I always keep getting errors. Any help is really appreciated.
Thank you!
Here is the script:
Content of the user.csv - two mailboxes just for testing:
When I execute all commands line by line they are working until the "ForEach" - that's where I get the following error:
If I change the user.csv into:
there is no error but there will also be no PST created...
Thank you for your help!
Best wishes
Alexander
we are using Veeam Backup & Replication 12 with Exchange 2016 on prem.
We are planning to export all Mailboxes into single PST files to import them into Exchange Online.
Exporting a single Usermailbox with the following code is working well.
Code: Select all
$restorepoint = Get-VBRApplicationRestorePoint -id 17d2c39d-e247-46e9-9507-dfc9c6d45601
Start-VBRExchangeItemRestoreSession -RestorePoint $restorepoint[0]
$session = Get-VBRExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session -Name "UserMailbox.edb"
$abrixmailbox = Get-VEXMailbox -Database $database -Name "Alexander Brix"
Export-VEXItem -Mailbox $abrixmailbox -To "C:\users\sysadministrator\Desktop\Alexander Brix.pst"
Thank you!
Here is the script:
Code: Select all
$restorepoint = Get-VBRApplicationRestorePoint -id 17d2c39d-e247-46e9-9507-dfc9c6d45601
Start-VBRExchangeItemRestoreSession -RestorePoint $restorepoint[0]
$session = Get-VBRExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session -Name "UserMailbox.edb"
$Mailboxes = Import-Csv C:\users\sysadministrator\Desktop\user.csv
ForEach ($mailbox in $Mailboxes) {
$user = Get-VEXMailbox -Database $database -Name $mailbox.name
Export-VEXItem -Mailbox $user -To "C:\users\sysadministrator\Desktop\PSTExport\$($mailbox.name).pst"
}
Code: Select all
Alexander Brix
Michael Müller
Code: Select all
Export-VEXItem : "System.Object[]" kann nicht in den Typ "Veeam.Exchange.PowerShell.Model.Items.VEXMailbox" konvertiert werden, der für den Parameter "Mailbox" erforderlich ist. Die angegebene Methode wird nicht
unterstützt.
In Zeile:3 Zeichen:32
+ Export-VEXItem -Mailbox $user -To "C:\users\sysadministrator\D ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Export-VEXItem], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Veeam.Exchange.PowerShell.Cmdlets.Export.ExportVEXItem
Code: Select all
Alexander Brix;Michael Müller
Thank you for your help!
Best wishes
Alexander
Who is online
Users browsing this forum: No registered users and 7 guests