We were completing a migration from Exchange 2016 to Exchange SE, and we found that when attempting to decommission the old Exchange Servers that we could not due to user accounts referring within the homeMDB attribute to a mailbox database on a legacy Exchange 2016 server. In some cases these didn’t actually have a mailbox that showed up when you ran “Get-Mailbox” within PowerShell; but would obviously block any removal of an Exchange Server.
You can therefore use something like the following, updating the DN as required for your environment and database name.
Get-ADUser -filter {homeMDB -eq "CN=DB1,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=MyCompany,CN=
Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=com"} -Properties * | Select-Object CN,samAccountName,WhenCreated,homeMDB | Format-Table
You can also add in a particular search base also if you need:
Get-ADUser -filter {homeMDB -eq "CN=DB1,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=MyCompany,CN=
Microsoft Exchange,CN=Services,CN=Configuration,DC=domain,DC=com"} -SearchBase "OU=People,OU=Myplace,DC=domain,DC=com" -Properties * | Select-Object CN,samAccountName,WhenCreated,homeMDB | Format-Table