Saturday, August 25, 2007

Who owns that email address?


Here is a one-liner to find which user owns a specific SMTP address in Exchange 2007.


>> (Get-Mailbox | ? {$_.EmailAddresses -match "^smtp:shay@homelab.loc"}).name
Shay Levi

And as a function


function Get-EmailOwner{
    param([string]$pat)
    $person = (Get-Mailbox | ? {$_.EmailAddresses -match "^smtp:$pat"}).name
    if($person) {$person} else{"No 1"}
}

No comments: