Quantcast
Channel: R&D Forums
Viewing all articles
Browse latest Browse all 9955

Veeam Backup for Microsoft 365 • Re: [Request] How to export bulk mailboxes to individual psts simultaneously through Powershell

$
0
0
Hey Mildur,

Thank you for pointing me in the right direction. I'm relatively new to PowerShell and a newbie, so I didn't know much about Start-Job. With that being said, I got the script to work for me!


Below is the script I used, which worked for me.

Code:

# Import Veeam modules in parent sessionImport-Module Veeam.Archiver.PowerShellImport-Module Veeam.Exchange.PowerShell# Get the organization and start restore session$organization = Get-VBOOrganization -Name "Org Name"Start-VBOExchangeItemRestoreSession -LatestState -Organization $organization# Get restore session and database info$session = Get-VBOExchangeItemRestoreSession$database = Get-VEXDatabase -Session $session# Save database ID (so it can be passed to jobs)$databaseId = $database.Id.Guid# Load CSV of mailboxes$mailboxes = Import-Csv C:\temp\mailboxes.csv# Create jobs for each exportforeach ($mailbox in $mailboxes) {    $name = $mailbox.Name    $sanitizedName = ($name -replace '[\\/:*?"<>|,]', '').Trim()    $outputPath = "V:\Downloaded PSTs\Test Exports\$sanitizedName.pst"    Start-Job -ScriptBlock {        param($orgName, $dbId, $mailboxName, $filePath)        # Re-import modules in the job context        Import-Module Veeam.Archiver.PowerShell        Import-Module Veeam.Exchange.PowerShell        # Re-establish session        $org = Get-VBOOrganization -Name $orgName        Start-VBOExchangeItemRestoreSession -LatestState -Organization $org | Out-Null        $session = Get-VBOExchangeItemRestoreSession        $database = Get-VEXDatabase -Session $session | Where-Object { $_.Id.Guid -eq $dbId }        $user = Get-VEXMailbox -Database $database -Name $mailboxName        Export-VEXItem -Mailbox $user -To $filePath    } -ArgumentList $organization.Name, $databaseId, $name, $outputPath}# Wait for all jobs to finish and check outputGet-Job | Wait-JobGet-Job | Receive-Job

Statistics: Posted by robotrobot94 — Jul 23, 2025 2:23 pm



Viewing all articles
Browse latest Browse all 9955

Latest Images

Trending Articles



Latest Images