Easily hide users from address book in Skype for Business/Lync via powershell

If you don't want users or other resources to appear in address book / GAL search in the Skype for Business client there is an easy way.
I made myself a tiny script for doing this:
This sets the attribute "msExchHideFromAddressLists" to True.
It also clears the attribute "ShowinAddressBook" 

This is the Script:

$users = Get-CsAdUser -Filter {name -Like "*test*"}


foreach ($object in $users)
    {
      Set-ADObject -Add @{msExchHideFromAddressLists=$true} -Identity $object.DistinguishedName
      Set-ADObject –clear ShowinAddressBook -Identity $object.DistinguishedName


  }

In this example i hide all the test users from showing up in address book search.

The top line can be changed to the selection of your choice.

Save the script as i.e. HideFromGal.ps1 and run it.

After running the script the objects will no longer show when you do an address book search in your Skype4B or Lync client.

Comments

  1. Do you need Exchange schema prep for this user attribute to be existing in the AD schema? Also another question, what is the consequence of clearing the other attribute value of "showinaddresbook"?

    ReplyDelete
  2. Hi. I believe the msExchHideFromAddressLists is added when implementing Exchange in your organization.
    The ShowInAddressBokk attribute specifies is not a boolean value end specifies which address book this user show be shown in. When clearing this attribute it will not show in any addressbook.
    You can read more about it here: http://www.techieshelp.com/non-exchange-users-showing-in-global-address-list-gal/

    ReplyDelete
    Replies
    1. Well, I think I need more investigation, as this topic smells more complicated than anticipated initially.

      Delete
  3. Is there a way to force a custom Address Book to a specific group of users in Skype for Business?
    Let's say I want a specific group of users in my organization to see only a part of the whole organization in the Skype for Business Client.

    ReplyDelete

Post a Comment

Popular Posts