Skip to content

Instantly share code, notes, and snippets.

@Apoc70
Last active September 17, 2024 10:02
Show Gist options
  • Save Apoc70/457f5c3abc6db841ffb37067ebe28543 to your computer and use it in GitHub Desktop.
Save Apoc70/457f5c3abc6db841ffb37067ebe28543 to your computer and use it in GitHub Desktop.
Move archive mailboxes from a selected mailbox database to other databases
# fetch archive mailboxes from database
$database = 'MBDB1925'
$mbx =Get-Mailbox -Database $database -Archive | ?{$_.ArchiveDatabase -eq $database}
# some variable
$file = ('e:\Temp\{0}ArchiveUsers.csv' -f $database)
$batchName = ('{0}-Archive-Offboarding' -f $database)
# prepare batch user CSV file
$mbx | Select-Object -Property @{Name = 'EmailAddress'; Expression = {$_.PrimarySMTPAddress}} | Export-Csv -Path $file -Encoding UTF8 -NoTypeInformation
# create migration batch
# change archive target database(s) to your needs
# the example distributes archive mailboxes across three databases
New-MigrationBatch -Name $batchName -CSVData ([System.IO.File]::ReadAllBytes($file)) -Local -TargetArchiveDatabases ARDB1901,ARDB1902,ARDB1903 -AutoStart -NotificationEmails johndoe@varunagroup.de -ArchiveOnly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment