Weekend Scripter: Automating the Preparation of Lync Server 2013—Part 2

Doctor Scripto

Summary: Automate the installation of SQL Server Express and complete the installation of Lync Server 2013.

Honorary Scripting Guy, Sean Kearney, is here. Today, we're getting a little nerdy by automating the rest of our Lync server…on a Sunday.

Yesterday, we finished with a Windows Server 2012 R2 box with all the features and the Visual C++ 2012 x64 Minimum Runtime package installed. We also have our schema for Active Directory extended.

Note  This is the second post in a series about Lync. Before you continue, you might enjoy reading Automating the Preparation of Lync Server 2013—Part 1.

Now we're going to dive in to the fun stuff. We'll spin up SQL Server Express in an automated mode, tuning the firewall, and more!

First, we need to get a SQL Server instance running. The software is sitting in the Lync 2013 media under the Setup\amd64 folder, and it is not difficult to run. If we let Lync run, it can do it for us.

But sometimes it's fun to figure it out for ourselves.

So normally, to install SQL Server 2012 Express, we would double-click SQLEXPR_x64.exe, and get a lovely little display like this:

Image of menu

If this is your first time installing SQL Server Express, it might appear a little daunting. Clicking on "New SQL Server stand-alone installation or add features to an existing installation" is your starting point.

But if you're curious, if you go to a CMD.EXE of the Windows PowerShell prompt and launch the application with a /?, you'll get to see the hidden keys to the chest.

SQLEXPR_x64.exe /?

Image of command output

With a little poking about, I (and some online BINGing) I found the combination of parameters to get SQL Server Express to install in the manner I wanted:


This will install a basic SQL Server Express instance with a name of SQLEXPRESS and all the basic features that are supplied in SQL Server Express.

If you'd like, you can also have Lync set up the firewall settings. But here's the cool part in Lync: read the windows! I noted that in many cases, Lync would actually display the console or the Windows PowerShell cmdlets that it was running. In this manner, you can prep the server before Lync gets to it.

If you'd like to have the firewall settings pre-enabled, here are some lines I scooped from the very log files you can use:

netsh advfirewall firewall add rule name="SQL RTC Access" dir=in action=allow program="c:\Program Files\Microsoft SQL Server\MSSQL11.RTC\MSSQL\Binn\sqlservr.exe" enable=yes profile=any

netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=UDP localport=1434

This will put in the much wanted firewall exceptions for SQL Server! (Tap, tap…how I wish SQL Server would do this for me. But of course, not every SQL Server instance needs to be network-enabled by default.)

More prep work?

In Windows Server 2012 R2, we can access the DNS records directly from Windows PowerShell. So I could actually prepare a script to populate the internal DNS server records required for Lync by using the ADD-DnsServerResourceRecord cmdlet.

Add-DnsServerResourceRecord –zone Contoso.local –Ipv4address –name sip –A –computername EOT-DC

Add-DnsServerResourceRecord –zone Contoso.local –Ipv4address –name meet –A –computername EOT-DC

Add-DnsServerResourceRecord –zone Contoso.local –name _sip –domainname sip.contoso.local –weight 0 –priority 0 –port 5060 –computername EOT-DC

…and of course the list goes on, but you get the idea. You could even prepopulate the records. Now if you were a really creative scripter, you could grab the topology XML file, parse its contents, and grab the names for DNS!

What's interesting to me as I poke about the folder structure, is how much of Lync is simply MSI files being called up in sequence. If you were to poke about under the hood of Setup\amd64, I'll bet…

But with the bulk of our requirements pre-installed, we can pop in our Lync media, launch our topolology creator and soon get to publishing the Lync infrastructure online!

Stop by tomorrow and we'll dig into Lync and it's Windows PowerShell cmdlets!

I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send an email to the Scripting Guys at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then just remember, the Power of Shell is in you.

Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy 


Discussion is closed.

Feedback usabilla icon