Dsc Tooling DevOpsGuys


i am trying to use the modified DSC Tools from DevOpsGuys and have tried the SampleBuild.ps1 (https://github.com/devopsguys/DSC/tree/development)

My current folder structure looks like this:

Folder PATH listing
Volume serial number is CA45-B0D3
│   ├───AllNodes
│   ├───Applications
│   ├───Credentials
│   ├───Services
│   └───SiteData
        │   ├───Calculator
        │   └───Validator
        │   └───Assertions

SampleBuild.ps1 is located at C:\DSC-development

    Import-Module Pester -ErrorAction Stop
    Import-Module dscbuild -ErrorAction Stop
    Import-Module dscconfiguration -ErrorAction Stop

    $params = @{
        WorkingDirectory = (Get-TempDirectory).FullName
        SourceResourceDirectory = "$PSScriptRoot\DSC_Resources"
        SourceToolDirectory = "$PSScriptRoot\DSC_Tooling"
        DestinationRootDirectory = 'C:\Program Files\WindowsPowerShell\DscService'
        DestinationToolDirectory = $env:TEMP
        ConfigurationData = Get-DscConfigurationData -Path .\DSC_Configuration -Force
        ConfigurationModuleName = 'SampleConfiguration'
        ConfigurationName = 'SampleConfiguration'
        Configuration = $true
        Resource = $true

    Invoke-DscBuild @params

    function Get-TempDirectory
        param ( )

            $tempDir = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath ([System.IO.Path]::GetRandomFileName())
        until (-not (Test-Path -Path $tempDir -PathType Container))

        return New-Item -Path $tempDir -ItemType Directory -ErrorAction Stop

When i run it i get the following message:
Import-Module : The specified module ‘Pester’ was not loaded because no valid module file was found in any module directory.

I am using Powershell v4 on Windows 2008 R2. Do i need to change provide the full path to the modules or am i missing something?`

Do i need to manually copy Pester,dscbuild,dscconfiguration to “C:\Program Files\WindowsPowerShell\Modules”


On target nodes, DSC resources need to be installed in one of the folders listed in PSModulePath, usually C:\Program Files\WindowsPowerShell\Modules. However, given the folder hierarchy you’ve shown, I don’t know what you’d copy. A DSC resource module must have at least a root .PSM1 file, and then a DSCResources subfolder, which I don’t see anywhere.

Have you considered contacting the authors?

Hi Don,

i hope that Dave Wyatt will answer this :slight_smile:


Everything that’s in your DSC_Tooling folder should exist in your PSModulePath (probably \Program Files\WindowsPowershell\Modules’ ) before you run Invoke-DscBuild. You would also need the SampleConfiguration module from the Tooling\Examples\ folder of the DSC repository in that location as well.

If you want to actually execute the sample build, you will need the StackExchangeResources, cWebAdministration and cSmbShare modules; those should be placed into your DSC_Resources folder, which will cause the Invoke-DscBuild command to test them and to produce zip files / checksums for them.

When we set up the TeamCity pipeline for DevOpsGuys, we created two steps. One was to install the dependencies (tooling modules, Pester, certificates needed for credentials encryption), and the second was to actually run Invoke-DscBuild. That first “install dependencies” step isn’t part of the DSC repo’s examples yet, but I’ll ask if it’s okay to share that as well.

On a side note, I haven’t really used the DSC_Tooling portion of Invoke-DscBuild yet, and I’m not sure what Steve’s use case for that was. I’ve been meaning to ask. It seems like a bit of a “chicken or egg” situation, since you need many of the tooling modules before you can run Invoke-DscBuild. That’s why we created a separate “Install Dependencies” step in TeamCity.

Hi Dave,

thanks now it works so far. I have a small problem or found a bug in DscConfiguration.psm1

    $LocalCertificateThumbprint = $null
Write-Warning "$($LocalCertificateThumbprint -eq $null)"
if ($null -eq $LocalCertificateThumbprint )
        $LocalCertificateThumbprint = "$((Get-DscLocalConfigurationManager).CertificateId)"
    catch { }

Result is:

So it never comes to this: $LocalCertificateThumbprint = “$((Get-DscLocalConfigurationManager).CertificateId)”

if i change this:

if ($null -eq $LocalCertificateThumbprint )

to this:

if (!$LocalCertificateThumbprint )

then it works to get the LocalCertificateThumbprint otherwise it is always empty.


Whoops, good catch. PowerShell converts $null to an empty string; that’s a common gotcha.

I think it’s probably a good idea to get rid of the arguments to the module itself; most people don’t even realize they’re there, and auto-loading the module misses that point anyway. That parameter would be more discoverable and intuitive in the commands that need to use the certificate. (You can already control the ConfigurationDataPath that way.)

Yeas maybe this would be a good idea.

I have seen your example and would like to know the purpose of Roles like “BaseServer”,“WebServer” for further use?

    Nodes = 'WebServer02'
    Roles = 'WebServer', 'BaseServer'

    BaseServerSettings = @{
        PowerPlan = 'High Performance'

Are the examples finished? Or is the “BaseServer” part missing?


That’s old stuff I forgot to remove. You no longer need a Roles key in your service hashtables. Will update that now.