Kevin Mychal Ong I noticed some time ago that ExternalDirectoryObjectId is actually stored as a string rather than a Guid, unlike most of the other Guid properties:
>Get-Mailbox | Get-Member -Name ExchangeGuid
TypeName: Deserialized.Microsoft.Exchange.Data.Directory.Management.Mailbox
Name MemberType Definition
---- ---------- ----------
ExchangeGuid Property System.Guid {get;set;}
>Get-Mailbox | Get-Member -Name ExternalDirectoryObjectId
TypeName: Deserialized.Microsoft.Exchange.Data.Directory.Management.Mailbox
Name MemberType Definition
---- ---------- ----------
ExternalDirectoryObjectId Property System.String {get;set;}
So my guess is -Identity is set to accept [string] objects and has a few aliases (UserPrincipalName, ExternalDirectoryObjectId) and either ValidateScript/ValidatePattern or some later logic figures out what was supplied. Identity too is likely the first declared parameter in the default set.
I'm just speculating on that stuff though. I've tried a few different ways to create my own -Identity parameters on scripts and have wondered what / how MS might get it done.