How to deploy a SMA worker via Powershell DSC

In my previous article around Powershell DSC I demonstrated some very basic example of what DSC can do. This article will go a bit deeper and show you a complete solution where Desired State Configuration can come in very handy.

I recently needed to deploy a couple of SMA (Service Management Automation) Runbook Worker machines. In this case I did not want to install them all manually, as I tend to forget some of the software requirements and I also don’t want to install too many unneeded server roles and features. I couldn’t find anything on the internet, so I thought I’d create a DSC config that will install all for me.

SMA software requirements



Runbook worker

Windows Server 2012 R2

Windows PowerShell 4.0

Automation web service

Windows Server 2012 R2

SQL Server 2012 (not Express edition)

Internet Information Services (IIS) 7.5 (hosts the web service)

IIS Basic Authentication

IIS Windows Authentication

IIS URL Authorization


.NET Framework 3.5 (for the Setup program)

.NET Framework 4.5

WCF HTTP Activation

Windows PowerShell module

Windows PowerShell 4.0


In total these are 11 Windows Features that I would need to remember, which I don’t want to remember. :)
On top of these 11 Features I also need to install the SMA Powershell module, the SMA Runbook Worker Service and I also want to install the SMA Web Service on those workers.

Add a Windows Feature via DSC

This example here shows how one Windows Feature resource in your DSC config will look like if you want to install the DotNet 3.5 features via DSC.

WindowsFeature DotNet35
	<span class="br0">{</span>
		Ensure <span class="sy0">=</span> <span class="st0">"Present"</span>
            	Name <span class="sy0">=</span> <span class="st0">"NET-Framework-Features"</span>
            	Source <span class="sy0">=</span> <span class="st0">"\\dc01\sources\OSD\OSSources\W12R2\sources\sxs"</span>
	<span class="br0">}</span>

I’m telling DSC here to install the WindowsFeature “NET-Framework-Features”. We all should know by now that we, if we want to add some certain Windows Features, need to supply the Windows Sources for the DISM process to grab the install files from.

Add an installation package via DSC

There are more resource keywords in DSC that you can use (even custom ones) than just the WindowsFeature, for example “Package“.

<span class="co1">#SMA Webservice</span>
Package SMAWebService
	<span class="br0">{</span>
        	Name <span class="sy0">=</span> <span class="st0">"System Center 2012 R2 Service Management Automation Web Service"</span>
                Path <span class="sy0">=</span> <span class="st0">"\\dc01\sources\Software\Microsoft\Orchestrator\SMA\WebServiceInstaller.msi"</span>
                ProductId <span class="sy0">=</span> <span class="st0">"4B76B636-AE9A-47D5-A246-E02909D97CF2"</span>
                Arguments <span class="sy0">=</span> <span class="st0">"/L*v C:\Windows\System32\LogFiles\SMAWebServiceInstaller.log SQLSERVER=<span class="es0">`"</span>CM01.DO.LOCAL,1433<span class="es0">`"</span> DATABASEAUTHENTICATION=<span class="es0">`"</span>SQL<span class="es0">`"</span> SQLDATABASE=<span class="es0">`"</span>SMA<span class="es0">`"</span> SQLUSER=<span class="es0">`"</span>sa<span class="es0">`"</span> SQLPASSWORD=<span class="es0">`P</span>@ssw0rd<span class="es0">`"</span> APPOOLACCOUNT=<span class="es0">`"</span>DO\SMA_AppPool<span class="es0">`"</span> APPOOLPASSWORD=<span class="es0">`"</span>P@ssw0rd<span class="es0">`"</span>"</span>
                Ensure <span class="sy0">=</span> <span class="st0">"Present"</span>
                DependsOn <span class="sy0">=</span> <span class="st0">"[Package]SMAPowershellModule"</span>
                ReturnCode <span class="sy0">=</span> <span class="nu0">0</span>
        <span class="br0">}</span>

This block will tell DSC the following:

  • The Package’s Name = SMAWebService
    • DSC will internally refer to that Package by this name
  • The Path to that Package
    • because we’re giving it an MSI, DSC is intelligent enough to call that MSI with the Windows Installer (clever, eh?)
  • The ProductID = DSC will find that Package by this ProductID
    • it then depends on what is defined under “Ensure” and it will either won’t try to execute that Package again or remove the package
  • Arguments = well, you know what Arguments do
  • Ensure = it’s either “Present” or “Absent
  • DependsOn = I’m telling it here, that that Package depends on the successful installation (or existence) of an other package
  • ReturnCode = configure a successful return code

More information on that Package resource can be found here:

Deploy a SMA Worker via DSC

Before the configuration was executed I took a quick snapshot of the features installed on that machine:

2014-07-10 18_56_46-SMAWorker01 on NB-DOBRIEN - Virtual Machine ConnectionKicking off the DSC cmdlet from the console looks like this:

Start-DSCConfigurationAfter the configuration was executed I can find a lot more installed features and also all three SMA components were successfully installed:

Get-WindowsFeatureRunning the whole block will create a DSC Push configuration on that machine you’re running it on (you can easily change it to something else) and enable you to install all needed prereqs to successfully add a new Worker to your SMA environment.
Note: I am not actually adding the Runbook Worker to your SMA Deployment, this still needs to be done by you via the following Powershell cmdlet: New-SmaRunbookWorkerDeployment -<ComputerName> –<WebServiceEndpoint>

Note: In my tests, if a machine had no internet connection while I installed the System Center SMA components, it took like 20 mins longer to install. Reason was that the WorkerInstaller.msi tries to execute an “Update-Help” via Powershell, which apparently takes a very long time to timeout. Just be aware of this.

Please first test this in a LAB environment before going into production! ;)

You can download the script from here: (0 downloads)

Or from the Technet Gallery:

You need to change all path references to the Windows installation source, the SMA sources and of course also the parameters for SMA installation!

Have fun automating!

- @david_obrien


Written by , Posted .