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

Doctor Scripto

Summary: Prep Windows Server 2012 R2 for a Lync Server 2013 installation.

Honorary Scripting Guy, Sean Kearney, is here, and today I'm doing something I've been itching to do for a while…Automate the creation of a Lync server!

You see, a while back, our Lync guy left the company. My boss looked at me and said, "You know anything about Lync?"

Ever been in one of those situations? Fortunately for me, I had spun up and managed OCS 2007 in the past, so it wasn’t completely scary.

One of our biggest challenges was disaster recovery. It appeared somewhere between "Spin up a Lync Server" and "Hand it off to infrastructure." Somebody forgot to create documentation for disaster recovery. *Oops!*

So it was in this process that I had to spin a Lync Server in a brand new configuration in the lab to see what it would take to install and manage. The nice part is it really wasn't that difficult. The cool part is there is a lot in the process that can be automated.

So our environment will be a simple one—a simple server Lync server. But the process for prepping that server is the key issue we're going to resolve. We're going to find out just how much we can automate our Lync setup.

Our environment includes two virtual machines:

  Machine 1:

  • Role: domain controller, Active Directory Certificate Services, DNS, DHCP
  • Name: Contoso-DC
  • Windows Server 2012 R2 Standard
  • 1 CPU, 1 GB Ram, 127 GB hard drive

  Machine 2:

  • Role: Lync Server 2013 Standard
  • Name: Contoso-Lync
  • Windows Server 2012 R2 Standard
  • 1 CPU, 4 GB Ram, 127 GB hard drive

We're going to presume you know how to spin up a new domain controller in Windows Server 2012 R2. If not, there are so many articles (including some in the Hey, Scripting Guys! Blog) to guide you in that aspect.

So first we plug that media into the Lync server and…Tada!

Being that this is a clean server, the first thing Lync wants to have installed is the Visual C++ 2012 x64 Minimum Runtime package:

Image of message

So of course, we'll let it do that. But if you would prefer to pre-install it yourself (which would skip by this little message), you can. This file is located under the Setup\amd64 folder within the Lync media. From this point forward, we will presume the DVD drive for Lync or mounted ISO is drive D.

You can pre-install it with this line:


This will provide a nice little progress bar as the runtime pre-installs.                 

Normally, you would go through the clicky, clicky, "wizard-o-matic." There is nothing wrong with that. It's a well designed system with checks and balances.

Our next step would be to extend the Active Directory schema.

We have two options for this. One, we write the lines directly with ldifde with credentials as a schema admin:

ldifde -i -v -k -s EOT-DC -f externalschema.ldf -c DC=X "DC=contoso,DC=local"

ldifde -i -v -k -s EOT-DC -f serverschema.ldf -c DC=X "DC=contoso,DC=local"

ldifde -i -v -k -s EOT-DC -f backcompatschema.ldf -c DC=X "DC=contoso,DC=local"

ldifde -i -v -k -s EOT-DC -f versionschema.ldf -c DC=X "DC=contoso,DC=local"

You could even wrap this in a CMD file so you can run this only once:

Rem First Parameter is Drive letter of Lync 2013 DVD Media or mounted ISO

Rem Second Paramater is Fqdn or Netbios Name of Domain Controller of domain to Extend Schema

Rem Third Parameter is Distinguished Name of Domain IE: "DC=Contoso,DC=local"

ldifde -i -v -k -s %2 -f %1\support\schema\externalschema.ldf -c DC=X %3

ldifde -i -v -k -s %2 -f %1\support\schema\serverschema.ldf -c DC=X %3

ldifde -i -v -k -s %2 -f %1\support\schema\backcompatschema.ldf -c DC=X %3

ldifde -i -v -k -s %2 -f %1\support\schema\versionschema.ldf -c DC=X %3

Then you'd have something like this, which would work fine:

ExtendLync.CMD D: EOT-DC "DC=Contoso,DC=local"

But Lync 2013 lives in Windows PowerShell, which is for making life easier. So first, let's automate the installation of the Lync core so we can gain access to the Lync module for Windows PowerShell:

MSIEXEC.EXE /I D:\Setup\AMD64\SETUP\ocscore.msi /passive /norestart

When the core completes installing, we can launch a simple Windows PowerShell script. We can extend the schema of the forest and the domain with three simple lines:




Now there is a whole pile of features that must be pre-installed for our Windows Server 2012 R2 to run Lync. They are:

  • Windows Desktop Experience
  • Windows Identity Foundation
  • IIS with the following features:

• Static Content

• Default Document

• HTTP Errors


• .NET Extensibility

• Internet Server API (ISAPI) Extensions

• ISAPI Filters

• HTTP Logging

• Logging Tools

• Tracing

• Windows Authentication

• Request Filtering

• Static Content Compression

• Dynamic Content Compression

• IIS Management Console

• IIS Management Scripts and Tools

• Anonymous Authentication (this is installed by default when IIS is installed.)

• Client Certificate Mapping Authentication

  • .NET Framework 3.5: This is critical. If you skip this step, Lync will continually fail to install.

We could sit there, clicking away to add these features. We could waste away a Saturday doing that… 

Or we could leverage the Install-WindowFeature cmdlet from Windows Server 2012 R2 and let the computer do all the work with a simple Windows PowerShell script:

Install-WindowsFeature Windows-Identity-Foundation

Install-WindowsFeature Web-Webserver

Install-WindowsFeature Web-Default-Doc

Install-WindowsFeature Web-Static-Content

Install-WindowsFeature Web-Http-Errors

Install-WindowsFeature Web-ASP-Net

Install-WindowsFeature Web-Net-Ext

Install-WindowsFeature Web-Isapi-Ext

Install-WindowsFeature Web-Isapi-Filters

Install-WindowsFeature Web-Http-Logging

Install-WindowsFeature Web-Http-Tracing

Install-WindowsFeature Web-Log-Libraries

Install-WindowsFeature Web-Windows-Auth

Install-WindowsFeature Web-Filtering

Install-WindowsFeature Web-Stat-Compression

Install-WindowsFeature Web-Dyn-Compression

Install-WindowsFeature Web-Mgmt-Console

Install-WindowsFeature Web-Scripting-Tools

Install-WindowsFeature Web-Client-Auth

Install-WindowsFeature Desktop-Experience

You could concatenate a lot of this into one line to improve speed, but you lose on readability. For this post, I'm going for readability because the following script would be so hard on the eyes:

Install-WindowsFeature Windows-Identity-Foundation Web-Webserver Web-Default-Doc Web-Static-ontent Web-Http-Errors Web-ASP-Net Web-Net-Ext Web-Isapi-Ext Web-Isapi-Filters Web-Http-Logging Web-Http-Tracing Web-Log-Libraries Web-Windows-Auth Web-Filtering Web-Stat-Compression Web-Dyn-Compression Web-Mgmt-Console Web-Scripting-Tools Web-Client-Auth Desktop-Experience

We now have a base server almost prepped for Lync! We still need to populate our SQL Server instance and install the rest of the server, but…

It's Saturday! Time to put up our feet and rest on a job well done!

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


Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon