Identify and reconnect disabled mailboxes in Exchange Online, 2013 and 2016

For a long time now, Exchange has allowed a grace period, during which mailboxes for deleted or “mail-disabled” AD users are still kept in the database. Sometimes, you might need reconnect such a mailbox to a newly created or pre-existing AD user object. In order for this to work, Exchange needs to know which mailboxes…