Have $Alias in the display


I can use the following command to find out all mailboxes which have the mailbox permission “Testing”.


    $list_Access = Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | where {$_.user -like "*Testing*"}| Select Identity

In the Select statement I want to be able to display the Alias instead of just the Identity. (The $Alias would have been retrieved as part of the “Get-Mailbox -ResultSize Unlimited”)

Any ideas. Please help.


Assuming the property name is indeed ‘Alias’, you should be able to supply it as an additional parameter to the final command there:

$list_Access = Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | where {$_.user -like "*Testing*"}| Select Identity, Alias

Or a bit more neatly laid out:

$list_Access = Get-Mailbox -ResultSize Unlimited | 
    Get-MailboxPermission | 
    Where-Object User -like "*Testing*" |
    Select-Object -Property Identity, Alias

Joel, Thanks for the input.
I was hoping for something along those lines, but just putting in the ALIAS at the end does not work.
Its not part of the fields that can be selected.
Try it in exchange and you will see what I mean.

I don’t think you can select a property of the mailbox object because it is no longer what’s in the pipeline by the end.
You could try collecting the mailboxes into a variable first, then doing a foreach as below to get your identity property from the mailbox permission object, and pull the alias off of the current iteration of mailbox in the foreach loop:

$mb = Get-Mailbox -resultsize unlimited
foreach ($item in $mb) {
    Get-MailboxPermission $item.Identity | where {$_.user -like "*Testing*"} | select identity,@{l="Alias";e={$item.alias}}}

That works great. Thank you