Have $Alias in the display

Welcome Forums General PowerShell Q&A Have $Alias in the display

This topic contains 4 replies, has 3 voices, and was last updated by

Hil
 
Participant
3 months, 3 weeks ago.

  • Author
    Posts
  • #103451
    Hil

    Participant
    Points: 0
    Rank: Member

    Hi,

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

    Script:

      $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.

    Thanks
    Hil

  • #103454

    Participant
    Points: 2
    Rank: Member

    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
    • #103457
      Hil

      Participant
      Points: 0
      Rank: Member

      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.

    • #103475

      Participant
      Points: 6
      Rank: Member

      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}}}
    • #103565
      Hil

      Participant
      Points: 0
      Rank: Member

      That works great. Thank you

The topic ‘Have $Alias in the display’ is closed to new replies.