Friday, 10 January 2014

Distribution Groups and Lync 2013 LHPv2 - Part 2

Yesterday I posted Part 1 of this blog here, so thought it prudent to get Part 2 out of the door as soon as possible.

Part 1 showed how to make existing mail enabled Distribution Groups show within the Lync client for Lync 2013 LHPv2 tenants. This part will show how to bulk prep all Distribution Groups for a tenant in Active Directory, ready for removal from SQL via the rtcDeleteAbEntry Stored Procedure

1. Import-Module ActiveDirectory

This will loads up the Active Directory shell

2. We now need to take the ObjectGUID of the tenants OU and append this to the msRTCsip-groupingID and msRTCSip-tenantID of each Distribution Group. Yesterday this was a manual process against a single Distribution Group to show you how it worked. Today we'll script it within Powershell so you can update all Distributions groups for a tenant.

Take the distinguishedName of the tenants OU (I am using the same tenant as I did for Part 1). Run in the Exchange Management Shell:

$OU = " OU=TestLyncPlan2013,OU=Provider,OU=Hosting,DC=hslab2,DC=net "

$OUObject = Get-ADOrganizationalUnit -Identity $OU

$GUID = $OUObject.ObjectGUID

What this is essentially doing is binding the Organizational Units distinguishedName to $GUID

3. If you want we can then do a quick count of the Distribution Groups in the tenants OU.

(Get-AdGroup -SearchBase $OU -filter *).count

4. We will now bulk set the missing msRTCSIP-GroupingID onto all the Distributions Groups above.

Get-AdGroup -SearchBase  $OU -filter * -Properties msRTCsip-groupingID |set-adgroup -Replace @{'msrtcsip-groupingid'=$GUID}

This is taking the Distribution Groups via the Get-AdGroup cmdlet and getting the property msRTCsip-groupingID. From there we are telling it to replace the value it finds with $GUID using Set-AdGroup

5. Let's now do the same again for the msRTCsip-TenantID:

Get-AdGroup -SearchBase  $OU -filter * -Properties msRTCsip-TenantID |set-adgroup -Replace @{'msrtcsip-tenantid'=$GUID}

6. That's it all done!

We can turn this into a Powershell script. This would look like the following (copy it and add it to a PS1 file locally):

# Lync 2013 LHPv2 Distribution Group bulk set for msRTCsip-GroupingID and msRTCsip-TenantID
# Oliver Moazzezi 2014

$OU = "Enter tenants DistinguishedName for OU here"

$OUObject = Get-ADOrganizationalUnit -Identity $OU

$GUID = $OUObject.ObjectGUID

Write-Host The total number of Distributions Groups for the Tenant are:
(Get-AdGroup -SearchBase $OU –filter * -Properties msRTCsip-groupingID).count

#We will now set the msRTCSIP-GroupingID

Get-AdGroup -SearchBase $OU -filter * -Properties msRTCsip-groupingID |set-adgroup -Replace @{'msrtcsip-groupingid'=$GUID}

#We will now set the msRTCSIP-TenantID:

Get-AdGroup -SearchBase $OU -filter * -Properties msRTCsip-TenantID |set-adgroup -Replace @{'msrtcsip-Tenantid'=$GUID}

Write-Host Distributions Group attributes completed successfully -foreground yellow

So now all the tenants Distribution Groups have the correct multi tenant attributes set. You can now export all their ObjectGUIDs as covered in Part 1, and begin the task of deleting them via the rtcDeleteAbEntry SQL Stored Procedure.

Part 3 will cover bulk automating this!

Take care

Oliver Moazzezi - MVP Exchange Server

No comments: