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

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]


Tom Arbuthnot is a consultant at Modality Systems providing planning, design and deployment of all aspects of Microsoft Unified Communications and integration with existing enterprise telephony environments. Before joining Modality, Tom worked for a leading Cisco Unified Communications Partner where he gained a good understanding of the Cisco UC proposition and a unique perspective on the relative benefits of the Microsoft offering. Tom is a Microsoft MVP for Lync and is actively involved in the global Unified Communications community via twitter, Microsoft Technet Forums and Lync’d Up blog. He holds a BSc degree in Management from Loughborough University as well as various technical certifications including Cisco CCNA Voice and Lync 2010 MCIPT.

Share This Post

Related Articles

5 Responses to “Script: Get-LyncDNSSRVRecords.ps1 check a list of domains for possible OCS\Lync federation”

  1. [...] for possible OCSLync federation | Lync’d Up Posted on November 1, 2011 by johnacook http://lyncdup.com/2011/11/script-get-lyncdnssrvrecords-ps1-check-a-list-of-d… Share this:StumbleUponDiggRedditLike this:LikeBe the first to like this [...]

  2. Julian Bee says:

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

  3. [...] A PowerShell script I wrote to scan domains for possible Lync Federation [...]

  4. [...] and Lync. I’ve had really good feedback on posts such as Lync PowerShell Cmdlet Mind Maps and PowerShell Script to check domains for Lync Federation, which keeps me motivated. The blog is currently averaging over ten thousand unique hits a month, [...]

Leave a Reply

© 2012 Lync'd Up. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress>