Sep 08 2017 07:08 AM - edited Sep 08 2017 08:00 AM
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 $_.name).title }}
Im problably missing something really simple here but i cant see it.
Sep 08 2017 09:45 AM
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 }}
Sep 08 2017 09:57 PM
SolutionI 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 $_.name |select Title New-Object -TypeName PSObject -Property @{ Name = $_.Name HiddenFromAddressListsEnabled =$_.HiddenFromAddressListsEnabled Title= $userinfo.Title } } |select Name,HiddenFromAddressListsEnabled,Title
Sep 11 2017 12:20 AM
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