Adding permissions in a cross-forest migration

This week I was working on a cross-forest migration, and instead of using linked mailboxes to set things up and moving mailboxes, I ended up using the CodeTwo migration tool. In that scenario I had live accounts in both forests, and I wanted to allow the users to continue to use their accounts in the original forest to access their mailboxes in the new forest.

To do this, I needed to use the Add-MailboxPermission command on each mailbox, giving their account in the other forest full access. Here’s what I ended up doing:

foreach ($Mailbox in (Get-Mailbox -ResultSize Unlimited)) { Add-MailboxPermission -identity "$($Mailbox.Name)" -AccessRights FullAccess -User "olddomain\$($Mailbox.Alias)" }