Author Posts

June 2, 2016 at 5:54 am

Hi I don't know why but when I used the example included in the xWebAdministration module, there seems to be an error. The goal is to setup a website in IIS and install certification. Here's the configuration script:

configuration Website_Setup
# Target nodes to apply the configuration
[string[]]$NodeName = 'localhost',

# Name of the website to create

# Source Path for Website content

# Destination path for Website content

# Import the module that defines custom resources
Import-DscResource -Module xWebAdministration

Node localhost
# Install the IIS role
WindowsFeature IIS
Ensure = "Present"
Name = "Web-Server"

# Install the ASP .NET 4.5 role
WindowsFeature AspNet45
Ensure = "Present"
Name = "Web-Asp-Net45"

# Stop the default website
xWebsite DefaultSite
Ensure = "Present"
Name = "Default Web Site"
State = "Stopped"
PhysicalPath = "C:\inetpub\wwwroot"
DependsOn = "[WindowsFeature]IIS"

# Copy the website content
File WebContent
Ensure = "Present"
SourcePath = $SourcePath
DestinationPath = $DestinationPath
Recurse = $true
Type = "Directory"
DependsOn = "[WindowsFeature]AspNet45"

# Create the new Website
xWebsite NewWebsite
Ensure = "Present"
Name = $WebSiteName
State = "Started"
PhysicalPath = $DestinationPath
DependsOn = "[File]WebContent"
ApplicationPool = 'AppPool'
BindingInfo = @(
Protocol = 'HTTP'
Port = '80'
IPAddress = '*'
HostName = ''


#Create certification. To be tested later on.

Protocol = 'HTTPS'
Port = '443'
CertificateThumbprint = '5438DC0CB31B1C91B8945C7D91B3338F9C08BEFA'
CertificateStoreName = 'WebHosting'
IPAddress = '*'


Start-DscConfiguration -Force -Wait -Verbose -Path .\Website_Setup

When I run the script above, here's what I input:

WebsiteName: Example_Website_v1
SourcePath: C:\inetpub\wwwroot
DestinationPath: C:\inetpub\wwwroot

And it will encounter an error like this:

PowerShell DSC resource MSFT_xWebsite failed to execute Set-TargetResource functionality with error message:
Failure to successfully create the website "Example_Website_V1".The object identifier does not represent a valid
object. (Exception from HRESULT: 0x800710D8)
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost

The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost

June 2, 2016 at 6:43 am


Couple of assumptions:
– I'm assuming you have the xWebAdministration module on the computer your running this script on. Based on the fact your using localhost, I assume your creating the mof file on the same server you want it applied to.

– I'm assuming you installed WMF 5.0 RTM at least on the server you want this applied on.

– I'm assuming you are running the ISE shell with administrative permissions

Things to check:
– Your using SourcePath in a wrong way. SourcePath in this sample means where are the web site files that I want to copy FROM the source
to a TargetPath. Theres no real sense in have SourcePath and DestinationPath be the same.

– Remove the #Create Certification... commen from within the xWebSite

– Try removing the HostName or leaving it blank in the HTTP binding

Off Topic:
The reason the script has the xWebSite DefaultSite section is to stop the default web site out of security concerns.
You should probably not use c:\inetpub\wwwroot either.

June 2, 2016 at 8:10 am

Hi Arie, Thanks for your prompt reply. Where should I place the certification script? Is the certification script right (the goal is installing a certification)?

  • This reply was modified 2 years, 2 months ago by  Hadrean Ocampo. Reason: clarification

June 2, 2016 at 11:17 am


Suggest reading Justins' blog about certificates and how to use them with DSC.
He is a frequent visitor to these forums so I'm sure he will pitch in about it.

Managing Certificates in DSC

Theres also a xCertificate DSC resource you could use, but I haven't had previous experience with it, so cant comment.

  • This reply was modified 2 years, 2 months ago by  Arie H.