Checking if a specific user account has mailbox access to another mailbox

Using the exchange management cmdlet you can query if a specific user has mailbox access to a particular mailbox account. Particularly useful if you are amending permissions and want to run error trapping.
$mailbox = "DomainUser1" # Mailbox to check
$username = "DomainUser2" # User account to look for


$user = get-mailbox $mailbox | Get-MailboxPermission | where { ($_.AccessRights -like "*FullAccess*") -and ($_.IsInherited -eq $false) -and ($_.User -like $username) }


If ($User -eq $null)
{
Write-Host "User:" $username "does not have access to" $mailbox "'s mailbox." -foregroundcolor red
}
Else
{

$DomUser = [String] $user.User

write-Host "User:" $username "has mailbox access to" $DomUser -foregroundcolor green

$mailboxenabled = $true
}

Leave a Reply

Your email address will not be published. Required fields are marked *