Subscribe via RSS Feed Connect on LinkedIn

Script: Get-LyncDNSSRVRecords.ps1 check a list of domains for possible OCS\Lync federation

01/11/2011 7 Comments

A few people in the community, including Julian Bee and Matt Landis are doing a great job of gathering information on what companies are open for Lync federation. Lync federation is one of the real killer features, being able to work with people across companies with IM, Presence, Voice, Video and sharing just like you do with you company colleagues is amazing.


The challenge was thrown down to write a script to gather the public DNS info that would suggest companies have Lync or OCS, which can be done with nslookup manually.


I thought that was a good idea. Not just to see which large companies are using Lync or OCS (and it’s quite a few btw), but also for any companies using Lync to scan the domains of the companies they work with to see who might be available for federation.

So I set about doing it in PowerShell. It was actually a bit of a challenge as [System.Net.Dns] doesn’t have a method to look up SRV records. Fortunately a community member had it covered with a dns module. Thanks to Joel ‘Jaykul’ Bennett.

So here is a script that takes a CSV list of domains and checks them for and records and writes the results to a text file.

Note: This is checking public DNS which the domain owner has chosen to publish, but please use it responsibly and at your own risk.

Feedback always welcome

Download the script here Other useful Lync scripts can be found here


[code lang=”ps”]

# Get-LyncDNSSRVrecords.ps1 Tom Arbuthnot
# This script scans a list of domains for SRV records that may indicate they may be running OCS/Lync and could
# be possible partners for federation. It writes the results to a text file
# Note: These are public DNS records, this is not getting anything not already published by the domain owner
# Use at your own risk, get the domain providers permission, look both ways before crossing the road.
# Example use: Take a list the common domains your company emails and check if any of them may be using OCS\Lync
# It expects a CSV with a single column titled domains
# This script requires PoshNet.dll from thanks Joel ‘Jaykul’ Bennett
# Feedback always welcome


# Variables to set

$domainscsvlist = ‘C:\Tom\domainstotest.csv’
$resultstxtfile = ‘C:\Tom\results.txt’
$poshnetdll = ‘C:\Tom\PoshNet.dll’


Import-Module $poshnetdll

$domains = Import-Csv $domainscsvlist

foreach ($row in $domains)
$domaintotest = $row.domain
$siptlscheck = Get-Dns _sip._tls.$domaintotest srv | select -ExpandProperty additionals | ft
$sipfederationtlscheck = Get-Dns _sipfederationtls._tcp.$domaintotest srv | select -ExpandProperty additionals | ft

if ($siptlscheck -ne $null)
Write-host SIP TLS Records found for $domaintotest
$domaintotest | Out-File -append C:\Tom\results.txt
“_sip._tls.$domaintotest” | Out-File -append C:\Tom\results.txt
$siptlscheck | Out-File -append C:\Tom\results.txt

if ($sipfederationtlscheck -ne $null)
Write-Host SIP Federation TLS Records found for $domaintotest
$domaintotest | Out-File -append C:\Tom\results.txt
“_sipfederationtls._tcp.$domaintotest” | Out-File -append C:\Tom\results.txt
$sipfederationtlscheck | Out-File -append C:\Tom\results.txt

Write-Host No records found for $domaintotest

$siptlscheck = $null
$sipfederationtlscheck = $null
Write-Host ‘Checks complete’


Useful? Please take a second to shareTweet about this on TwitterShare on LinkedInShare on Google+Email this to someone
Tom Arbuthnot

Tom Arbuthnot

Principal Solutions Architect at Modality Systems
Tom Arbuthnot is Principal Solutions Architect at Unified Communications specialist Modality Systems. He is a Microsoft Certified Master and MVP, blogger, regular on The UC Architects Podcast, and speaker at events including Microsoft Lync Conference, TechEd and Ignite. He co-runs The Microsoft UC User Group London.
Tom Arbuthnot
Filed in: Lync, Microsoft • Tags: , , ,

Comments (7)

Trackback URL | Comments RSS Feed

  1. Julian Bee says:

    Thanks for the mention. Federation really is a game-changer, and that script is a fantastic tool. Nice work!

  2. Jeff says:

    So I know this script os 4 years old… Hoping I will still get an answer.

    I have changed some of the params for the records to fetch. I can run the lookups fine from NSLookup, but I am not receiving the expected results when running this script.

    I have even set the IP for our internal DNS on the get-dns script.

Leave a Reply