If you have a hybrid Exchange infrastructure, it appears that you can query your local Active Directory to find out users who have already been migrated to Exchange Online.
Thanks to the attribute named msExchRecipientTypeDetails (values detailed here), you can find these accounts with a remote mailbox.
Here’s a small function that leverages this msExchRecipientTypeDetails attribute:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-RemoteUserMailbox { | |
[CmdletBinding()] | |
Param( | |
[Parameter()] | |
[string]$SearchBase = "$((ActiveDirectory\Get-ADDomain).DistinguishedName)", | |
[Parameter()] | |
[int32]$ResultSetSize = 10000, | |
[Parameter()] | |
[string]$SearchScope = 'SubTree' | |
) | |
Begin {} | |
Process { | |
$HT = @{ | |
Filter = 'msExchRecipientTypeDetails -eq 2147483648' | |
SearchScope = $SearchScope | |
ResultSetSize = $ResultSetSize | |
SearchBase = $SearchBase | |
ErrorAction = 'Stop' | |
} | |
try { | |
ActiveDirectory\Get-ADUser @HT | |
} catch { | |
Write-Warning -Message "Failed to query AD because $($_.Exception.Message)" | |
} | |
} | |
End {} | |
} |
You can even bind cmdlets like this for example:
Get-RemoteUserMailbox | Get-ADUser -Properties AccountExpirationDate | Out-GridView
Nice, isn’t it? 😀