Exchange Management Shell: Getting title in Get-Mailbox for all results

New Contributor

I am trying to get a list of mailboxes that have been hidden from the GAL.
The results have the contain there name, a true or false for HiddenFromAddressListsEnabled and there (job)title.
The problem is that the title can only be called with Get-User. I found how to combine the two. 
But the result only show the Title on the last result.

Sofar i have this. For testing limited to 10

Get-Mailbox -ResultSize 10 | Select Name,HiddenFromAddressListsEnabled, @{n="Title";e={(get-user $ }}

Im problably missing something really simple here but i cant see it.

3 Replies

Don't use the Name property, or any other property that is not unique - you will get incomplete/broken set of results. Also, remember that Title is not a mandatory attribute and can be empty.


Anyway, your example works fine, I just adjusted it to use the UPN:


Get-Mailbox -ResultSize 10 | Select Name,HiddenFromAddressListsEnabled, @{n="Title";e={(Get-User $_.UserPrincipalName).title }}



best response confirmed by JoSoFine (New Contributor)

I think you are using old version of powershell (2.0) so that you got in-correct result and "name" is also  unique value 

Here I have modified the script and this script will work for all the powershell version.

$users = Get-Mailbox -ResultSize 10 | Select Name,HiddenFromAddressListsEnabled
$users | Foreach-Object{

$userinfo=Get-user $ |select Title
New-Object -TypeName PSObject -Property @{
      Name = $_.Name
      HiddenFromAddressListsEnabled =$_.HiddenFromAddressListsEnabled
      Title= $userinfo.Title

} |select Name,HiddenFromAddressListsEnabled,Title

This seems to work sofar, thanks.
Title can indeed be empty, but in our situation that will only happen with very few mailboxes.
Thanks you