2
votes

I am trying to use the xWebsite resource in powershell DSC but it keeps failing to Set-TargetResource. the error is

PowerShell provider MSFT_xWebsite  failed to execute Set-TargetResource functionality with error message:  
+ CategoryInfo          : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure

The resource looks like

    WindowsFeature IIS 
{ 
  Ensure = “Present” 
  Name   = “Web-Server” 
} 
    xWebsite Website
{
    Ensure       = "Present"
    Name         = "Website"
    PhysicalPath = "E:\www\site"
    State        = "Started"
    BindingInfo  = MSFT_xWebBindingInformation 
    {
        Protocol = 'HTTP'
        Port     = 7777
        HostName = '*'
    }

    DependsOn    = "[WindowsFeature]IIS"
}

I just copied it from one of the DSC examples, and initially it did not return the above error. I do not know what changed, but now it cannot create the website on subsequent runs. There is not a lot of troubleshooting content on DSC yet either, and I am hoping that someone else has run into this problem as well.

2

2 Answers

1
votes

Regarding the initial run not returning an error

This may be related to this bug.

Regarding the error itself

Let's check the obvious stuff first:

  1. All components of the PhysicalPath must exist; the resource won't create any of those paths. So use a File resource to create them if needed then make xWebsite depend on it.
  2. Make sure a different web site is not using the port.
  3. You show a DependsOn but don't show the rest of your configuration. Make sure that you're actually specifying a WindowsFeature resource in your config for it to depend on.

If those don't help

Post the rest of your config (if there is more).

Check out the xDscDiagnostics module in the DSC Resource Kit. It's not a resource, it's 2 functions that help you turn on the diagnostic and debug logs for DSC and then retrieve the events related to a specific run. This should help you figure out the actual underlying error.

1
votes

I ran into problems trying to use the xWebsite resource on Windows Server 2008 R2 too. Then I noticed that at the bottom of the documentation page, it says:

Verified on the following platforms

Windows Server 2012: Yes

Windows Server 2008 R2: No

I ended up debugging through the module code outside of DSC. I found that there were several bits that didn't work on 2008R2, and so had to create my own version of the module that worked on that operating system.

Sorry - no easy fix!