Skip to content

Instantly share code, notes, and snippets.

@Apoc70
Last active September 17, 2024 08:59
Show Gist options
  • Save Apoc70/74b83655fa88ba3c26ca4df99ccfb796 to your computer and use it in GitHub Desktop.
Save Apoc70/74b83655fa88ba3c26ca4df99ccfb796 to your computer and use it in GitHub Desktop.
A few PowerShell lines for creating a new local mailbox migration batch
# Fetch all user mailboxes from database MBXDB01
$mbx = Get-Mailbox -Database MBXDB01
# Export fetched mailboxes to CSV
# Export using EmailAddress as fixed column header for batch creation
$mbx | Select-Object -Property @{Name = 'EmailAddress'; Expression = {$_.PrimarySMTPAddress}} | Export-Csv -Path C:\Temp\MBXDB01Users.csv -Encoding UTF8 -NoTypeInformation
# Create new migration batch with automatic start and automatic complete
# Distribute mailboxes to target databases MBXDB11, MBXDB12, MBXDB19
# Primary and an exisiting archive
New-MigrationBatch -Name 'MBXDB01-Offboarding' -CSVData ([System.IO.File]::ReadAllBytes("C:\Temp\MBXDB01Users.csv")) -Local -TargetDatabases MBXDB11,MBXDB12,MBXDB19 -AutoStart -AutoComplete -NotificationEmails someone@varunagroup.de
# Primary Only
New-MigrationBatch -Name 'MBXDB01-Offboarding' -CSVData ([System.IO.File]::ReadAllBytes("C:\Temp\MBXDB01Users.csv")) -Local -TargetDatabases MBXDB11,MBXDB12,MBXDB19 -AutoStart -AutoComplete -PrimaryOnly -NotificationEmails someone@varunagroup.de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment