I got a requirement to connect disconnected mailboxes and move them to another database. So I created script for the same. You can use the same in your environment. There are few changes which needs to be perform in this script.
You need to put target Database name where you want to move mailbox after connecting. Setting will be under $targetDB.
Another setting is OU where disconnected mailboxes account will reside after connecting.
Please modify settings as per your environment requirement and make sure to test it in test environment before running it on Production.
Disconnnectedmailboxes.ps1 -database DB1
Here Db1 is database on which disconnected mailboxes residing.