[Migrated from MSDN Exchange Dev] PowerShell to pull Full access from exchange account

Eric Yin-MSFT 4,396 Reputation points
2020-12-08T01:30:36.927+00:00

Origin link: https://social.msdn.microsoft.com/Forums/office/en-US/a578f9a3-d42f-47e2-b612-f31654b5684a/powershell-to-pull-full-access-from-exchange-account?forum=exchangesvrdevelopment&prof=required

I wrote this simple script to grab names and user ID's who have full access to a mailbox. It ran once, but now won't run again. Any help with syntax will be appreciated:

$perm = get-mailboxpermission -identity [Mailboxname] | Where{$.User -like "U*" -and $.AccessRights -Like "FullAccess*"}

Foreach ($perm in $perms)
{

get-mailbox $perm.User | Select Name, Alias

}

If I look at the variable $perm.User, it is grabbing the user ID's I want, but for some reason the get-mailbox command is just returning nothing.

Exchange Exchange Server Management
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Eric Yin-MSFT 4,396 Reputation points
    2020-12-08T02:41:43.903+00:00

    $perm.user will get results like "contoso\username", which cannot be identity of Get-Mailbox.
    Try the following commands please:

    $perms = get-mailboxpermission -identity user | Where{$_.User -like "U*" -and $_.AccessRights -Like "FullAccess*"}  
    $perms | select @{Name="User";expression={(Get-Recipient $_.user.tostring()).displayname}} | foreach{  
    get-mailbox $_.User  | Select Name, Alias  
    }  
    

    Reference link: https://social.technet.microsoft.com/Forums/office/ru-RU/1a4c34a2-345a-45fc-88bd-87b020dd3d59/get-full-name-from-getmailboxpermission?forum=exchangesvrdevelopment


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.