We help IT Professionals succeed at work.

Get-Exchange mailbox users

AhmedAliShaik
on
As per our client requirement we need to generate a report of all unity servers users who are enabled/not enabled in GAL in the below format (hide from Addresslist)

displayName  sAMAccountName  email  msExchHideFromAddressLists  Description server

I have tried a script which gives me the users who are not enabled from GAL, but getting output in a different format.

$serverlist = "C:\unity.txt"

foreach ($server in Get-Content $serverlist)
{

Get-Mailbox -ResultSize unlimited |Where{($_.servername -eq "$server") -and ($_.HiddenFromAddressListsEnabled -eq $false)}

}

the format i am getting is
  Name      Alias      ServerName

Can u help me in finetuning this script to get the required format
Comment
Watch Question

Manpreet SIngh KhatraSolutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013

Commented:
Get-Mailbox -ResultSize unlimited |Where{($_.servername -eq "$server") -and ($_.HiddenFromAddressListsEnabled -eq $false)} | FL DisplayName, sAMAccountName, email, msExchHideFromAddressLists, Server

- Rancy

Author

Commented:
I accept with you, but the powershell gives only the mailboxes where the msExchHideFromAddressLists is false.

Please correct me if i am wrong.

I need all the list and will filter it manually by the msExchHideFromAddressLists result as per requirement.
Solutions Architect, Project Lead
CERTIFIED EXPERT
Top Expert 2013
Commented:
Get-Mailbox -ResultSize unlimited |Where{($_.servername -eq "$server") | FL DisplayName, sAMAccountName, email, msExchHideFromAddressLists, Server

- Rancy

Author

Commented:
Rancy :- Thanks a lot.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.