9

I'm trying to write powershell script which hides user from exchange lists.

I was able to find following command: Set-Mailbox -Identity [user id here] -HiddenFromAddressListsEnabled $true

And it doesn't give me an error message, and when I run the command twice, I get following warning:

WARNING: The command completed successfully but no settings of '[user id here]' have been modified.

Which probably means that the command did actually work.

but when I go to Exchange Management Console, and open user profile, "hide user from exchange address lists" check box is off.

What could be the reason?

Vova Zaycev
  • 258
  • 1
  • 3
  • 11
  • Try these links and see if they are helpful: - http://vnucleus.com/2011/07/hide-disabled-users-from-exchange-2007-gal-via-powershell/ - http://forums.msexchange.org/m_1800498374/mpage_1/key_/tm.htm#1800498374 – Aman Dhally Nov 04 '11 at 19:01

6 Answers6

7

I use this as a daily scheduled task to hide users disabled in AD from the Global Address List

$mailboxes = get-user | where {$_.UserAccountControl -like '*AccountDisabled*' -and $_.RecipientType -eq 'UserMailbox' } | get-mailbox  | where {$_.HiddenFromAddressListsEnabled -eq $false}

foreach ($mailbox in $mailboxes) { Set-Mailbox -HiddenFromAddressListsEnabled $true -Identity $mailbox }
Rob Millerd
  • 71
  • 1
  • 2
2

You can use the following script, just replace DOMAIN with the name of your domain. When executed it will prompt you for a userlogin then hide that user's account from the address lists.

$name=Read-Host "Enter login name of user to hide"
Set-Mailbox -Identity DOMAIN\$name -HiddenFromAddressListsEnabled $true

Brian.

Brian
  • 21
  • 2
  • 1
    This is exactly what I'm using, and it sets the value, however when I go to Exchange Management Console, and open user profile, "hide user from exchange address lists" check box is off. – Vova Zaycev Feb 29 '12 at 19:46
1

I was getting the exact same error, however I solved it by running $false first and then $true.

Ivan Ferić
  • 4,725
  • 11
  • 37
  • 47
Jiberoony
  • 11
  • 1
0

"WARNING: The command completed successfully but no settings of '[user id here]' have been modified."

This warning means the setting was already set like what you want it to be. So it didn't change anything for that object.

0

For Office 365 users or Hybrid exchange, go to using Internet Explorer or Edge, go to the exchange admin center, choose hybrid, setup, chose the right button for hybrid or exchange online.

To connect:

Connect-EXOPSSession

To see the relevant mailboxes:

Get-mailbox -filter {ExchangeUserAccountControl -eq 'AccountDisabled' -and RecipientType -eq 'UserMailbox' -and RecipientTypeDetails -ne 'SharedMailbox' }

To block based on the above idea of 0KB size:

Get-mailbox -filter {ExchangeUserAccountControl -eq 'AccountDisabled' -and RecipientTypeDetails -ne 'SharedMailbox' -and RecipientType -eq 'UserMailbox' } | Set-Mailbox -MaxReceiveSize 0KB -HiddenFromAddressListsEnabled $true

0

You will have to pass one of the valid Identity values like DN, domain\user etc to the Set-Mailbox cmdlet. Currently you are not passing anything.

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • manojlds, I put User ID in inequality signs and it wasn't displayed. Actually this is not the issue, and valid ID was provided. Sorry for that – Vova Zaycev Nov 02 '11 at 14:13