Use Lync Address book segregation

Today I want to share how we implement the Lync Address book segregation function in Lync 2010. In our organization where we need to separate several Organizations from seeing each other in the Lync Address book we had to find a solution.
We used several PowerShell commands to achieve this function. Our users are all in the same OU who needs to share the same address book.
We first import the AD PowerShell Module:

Import-Module ActiveDirectory

Then we sort out the OU where we need the OU GUID from.

$OU = “OU=Users,OU=Department,DC=Domain,DC=Corp”
$OUObject = Get-ADOrganizationalUnit -Identity $OU
$GUID = $OUObject.ObjectGUID

After getting the OU ObjectGUID we set this GUID as the msRTCSIP-GroupingID option for all users in that OU:

Get-ADUser -LDAPFilter “(ObjectClass=user)” -SearchBase $OU -Properties msRTCSIP-GroupingID,msRTCSIP-PrimaryUserAddress,comment |Set-ADUser -Replace @{‘msRTCSIP-GroupingID’=$GUID} -verbose

After that we run a update of the address book and we start enabling Lync users via the GUI or Powershell.

Update-CsAddressBook

Then we start enabling users for Lync!
If you have accidently enabled user before enabling it for Addressbook segregation it helped for me to run  Update-CsUserDatabase and delete the local addressbook from user profile. If that doesn’t work out for you remove the user from lync and adding it again.