2

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?)

Matt
  • 3,241
  • 9
  • 30
  • 33

1 Answers1

4

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"
}
Matt
  • 3,241
  • 9
  • 30
  • 33
Chris
  • 56
  • 1
  • Awesome, didn't know this was an option in DSC. Will try this out. – Matt Feb 26 '16 at 03:13
  • Thank you so much Chris. I have proposed an edit based on some additional tweaking I had to do, but this got me 95% there. I had to add some `arguments` to get it to do a complete install, namely `Arguments = "LicenseAccepted='0' ADDLOCAL=ALL"`, and research suggests `WebManagementService` (Web-Mgmt-Service) is a pre-req. – Matt Feb 26 '16 at 03:50
  • @Matt - I personally don't think you should be editing Chris' answer. I'd encourage him to do so. You accepted his answer, but your proposed edits change/add quite a bit. – David Makogon Feb 26 '16 at 03:56
  • @DavidMakogon Are you suggesting that I should make the person who took time out of their day to update their own answer to more accurately capture a more complete answer? Based on my own additional research that I would only be communicating via a comment? Instead of just letting Chris or others to choose whether or not to accept or decline the *proposed* changes that I can spend my own time contributing to ServerFault? – Matt Feb 26 '16 at 05:13
  • 1
    FYI, 3.6 is the latest version of Web Deploy - https://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi – Richard Szalay Aug 05 '16 at 02:18
  • Make sure your slashes in your paths are \ and not /, otherwise you may get product ID GUID errors. – rebelzach Jul 23 '21 at 05:24