Last active
November 19, 2024 07:43
-
-
Save Apoc70/457f5c3abc6db841ffb37067ebe28543 to your computer and use it in GitHub Desktop.
Move archive mailboxes from a selected mailbox database to other databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fetch archive mailboxes from database | |
$database = 'MBDB1925' | |
$mbx =Get-Mailbox -Database $database -Archive | ?{$_.ArchiveDatabase.Name -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 [email protected] -ArchiveOnly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment