When performing an AD migration it is sometimes necessary to make the mailbox a linked mailbox so that the migrated user can continue to use their email. When searching online I found the official answer from Microsoft which is to disable-mailbox and then connect-mailbox, however this loses all of the Exchange related attributes. Of course you can back those up and apply them again later but that is a bit of a pain.
Searching a bit further I found people talking about Set-User and the -LinkedMasterAccount parameter. This is used to convert a linked mailbox back to a standard mailbox by passing the value $null. Now Microsoft do not talk about using it for the opposite but it does work.
So here is a script that will convert a mailbox to a linked mailbox while preserving all of the Exchange related attributes.
*** As always the script is provided on an as is basis, please test it before you use it in a production environment. ***