Windows – Installing Web Deploy with Desired State Configuration (DSC) silently fails

dscpowershellwindowswindows-server-2012-r2

Absolutely brand new to DSC, so I am really stumbling through things right now. I have a basic configuration that ensures IIS, .NET 4.5, and MSMQ are installed. I am working toward configuring a new Windows 2012 R2 instance to support our applications. Currently our applications are deployed using powershell over Web Deploy (the artifacts are built with PSake/MSBuild in TeamCity).

So the next step I am trying to take with DSC is getting Web Deploy installed on the target server. This is an MSI download, and not a "Windows Feature" that I can simply Ensure is installed.

So I have a custom Script in my DSC that tries to do an un-attended install of an the Web Deploy MSI file. The script

Script InstallWebDeploy
{
    GetScript =
    {
        $false
    }
    SetScript =
    {
        $cmd = "MSIEXEC /a 'C:\Temp\WebDeploy_amd64_en-US.msi' /passive" # have also tried /qn
        (Start-Process -FilePath "msiexec.exe" -ArgumentList "/a 'C:\Temp\WebDeploy_amd64_en-US.msi' /passive" -Wait -Passthru).ExitCode
    }
    TestScript =
    {
        $false
    }
}

The result, after generating the .mof and using it, gives me:

VERBOSE: [CORAPP4]: LCM:  [ Start  Resource ]  [[Script]InstallWebDeploy]
VERBOSE: [CORAPP4]: LCM:  [ Start  Test     ]  [[Script]InstallWebDeploy]
VERBOSE: [CORAPP4]: LCM:  [ End    Test     ]  [[Script]InstallWebDeploy]  in 0.0000 seconds.
VERBOSE: [CORAPP4]: LCM:  [ Start  Set      ]  [[Script]InstallWebDeploy]
VERBOSE: [CORAPP4]:                            [[Script]InstallWebDeploy] Performing the operation "Set-TargetResource"
 on target "Executing the SetScript with the user supplied credential".
VERBOSE: [CORAPP4]: LCM:  [ End    Set      ]  [[Script]InstallWebDeploy]  in 1.0430 seconds.
VERBOSE: [CORAPP4]: LCM:  [ End    Resource ]  [[Script]InstallWebDeploy]
VERBOSE: [CORAPP4]: LCM:  [ End    Set      ]    in  4.4783 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 4.214 seconds

However, Web Deploy is no-where in sight on the server. (I realize the Get-Script and Test-Script need fleshing out, but wanted to reduce the number of variables involved here)

Any idea why this is failing? (but without apparent error?)

Best Answer

Since you are using DSC with a msi file I suggest using the Package Resource. You can then ensure that it's installing instead of using a custom script resource. Please note that the name and Product ID property must match the package. I have put an example based on the package you want to install below.

Link to Package Resource documentation: Package Resource MSDN

WindowsFeature WebManagementService
{
    Ensure = "Present"
    Name = "Web-Mgmt-Service"
}

Package WebDeploy
{
     Ensure = "Present"
     Path  = "$Env:SystemDrive\TestFolder\WebDeploy_amd64_en-US.msi"
     Name = "Microsoft Web Deploy 3.5"
     LogPath = "$Env:SystemDrive\TestFolder\logoutput.txt"
     ProductId = "1A81DA24-AF0B-4406-970E-54400D6EC118"
     Arguments = "LicenseAccepted='0' ADDLOCAL=ALL"
}