Subscribe via RSS Feed Connect on LinkedIn

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

01/11/2011 5 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.

image

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.

image

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  _sip._tls.domain.com and _sipfederationtls._tcp.domain.com 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 lyncdup.com
#
# 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 http://huddledmasses.org/powershell-dig-nslookup-cmdlet/ 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
}

else
{
Write-Host No records found for $domaintotest
}

$siptlscheck = $null
$sipfederationtlscheck = $null
}
Write-Host 'Checks complete'

[/code]

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

Tom Arbuthnot

Managing Consultant at Modality Systems
Tom Arbuthnot is a Microsoft Lync Certified Master and MVP. He is a blogger, regular on The UC Architects Podcast, contributing writer to Lync Server 2013 Unleashed and speaker at events such as Lync Conference and The Microsoft UC User Group London. He is currently Managing Consultant at Modality Systems.
Tom Arbuthnot
Filed in: Lync, Microsoft • Tags: , , ,

Leave a Reply