Powershell command to hide user from exchange address lists
Asked Answered
P

6

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?

Palmation answered 1/11, 2011 at 23:36 Comment(1)
Try these links and see if they are helpful: - vnucleus.com/2011/07/… - forums.msexchange.org/m_1800498374/mpage_1/key_/…Bitty
D
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 }
Delate answered 2/7, 2015 at 23:18 Comment(0)
O
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.

Orlando answered 16/2, 2012 at 13:23 Comment(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.Palmation
C
1

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

Centuple answered 15/2, 2013 at 13:34 Comment(0)
H
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.

Homocyclic answered 1/11, 2011 at 23:41 Comment(1)
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 thatPalmation
P
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.

Pulsate answered 3/3, 2017 at 17:58 Comment(0)
T
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

Toussaint answered 20/6, 2019 at 0:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.