How to create an SRV record using DNS PowerShell

February 27, 2012 by Thomas Foreman in IT Infrastructure

We struggled the other day trying to figure out how to create a DNS SRV record using DNS PowerShell (DnsShell).

First off, DnsShell is a tool to administer and configure Microsoft Domain Name System (DNS). It is built to work in Windows PowerShell 2.0 and you will find it here.

The forums on the site didn’t help us, and we also didn’t find much help from our online searches. But we eventually figured it out, and after some validation testing, I thought it would be useful to share the correct syntax that you can use to create one.

We were trying to script how to create some Service Location (SRV) records for Lync Server 2010 that would point to the FQDN of our Microsoft Access Edge Server. This would allow external Lync 2010 clients to automatically log on, and it would work the same for OCS as well.

This is the command that we used with the correct syntax:

New-DnsRecord -RecordType SRV -Server DC01.onprem.local -ZoneName onprem.domain.com -TTL 3600 -Priority 0 -Weight 0 -Port 5061 -TargetName sip.onprem.domain.com -Name “_sipfederationtls._tcp”

Some of the variables are obvious, like RecordType, TTL, Port, Weight and Priority. So I won’t go over those, but here are the ones that were trickier and less obvious to correctly configure:

  • -Server should point to your Certification Authority, which in the above example is DC01.onprem.local.
  • -ZoneName is the DNS zone name where you want the records created which should be the same as your SIP domain.
  • -TargetName is the FQDN of the host providing the service, which is your SIP Access Edge Server. This should be sip.sipdomain, and in the above example it is sip.onprem.domain.com.
  • -Name is the service and the required protocol. For a Lync External DNS SRV record, this is _sipfederationtls and the protocol is _tcp.

When finished configuring the command, you can run it to create an SRV record that look similar to this:

SRV Records Using PowerShell

You can then easily modify the command to create your other required external SRV records for Lync Server 2010, such as in the following example:

New-DnsRecord -RecordType SRV -Server DC01.onprem.local -ZoneName onprem.domain.com -TTL 3600 -Priority 0 -Weight 0 -Port 5061 -TargetName sip.onprem.domain.com -Name “_sip._tls”

Hope this information helps you to create reliable SRV records for Lync Server 2010.