I'm working through the DSC book from powershell.org and trying to setup a pull server using the configuration code specified in the book.
configuration CreatePullServer
{
param
(
[string[]]$ComputerName = 'localhost'
)
Import-DSCResource -ModuleName xPSDesiredStateConfiguration
Node $ComputerName
{
WindowsFeature DSCServiceFeature
{
Ensure = "Present"
Name = "DSC-Service"
}
xDscWebService PSDSCPullServer
{
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
}
xDscWebService PSDSCComplianceServer
{
Ensure = "Present"
EndpointName = "PSDSCComplianceServer"
Port = 9080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
CertificateThumbPrint = "AllowUnencryptedTraffic"
State = "Started"
IsComplianceServer = $true
DependsOn = ("[WindowsFeature]DSCServiceFeature","[xDSCWebService]PSDSCPullServer")
}
}
}
CreatePullServer -ComputerName pull1.lab.pri
When I run the configuration script, powershell reports that it is unable to load the xPSDesiredStateConfiguration module.
Import-DSCResource -ModuleName xPSDesiredStateConfiguration Unable to load module 'xPSDesiredStateConfiguration': module not found.
I verified that I have the DSC resource kit installed, and the module is listed when I execute the Get-DSCResource command. Can anyone give me a clue as to what I may have done wrong?
Also, I am using Windows 7 64-bit and have installed KB2819745 to bring powershell up to version 4.
Responding to a comment to my original question, I checked that the module was being listed when executing Get-Module -ListAvailable
. I noticed that when I ran the command it was listing the directory containing the module twice. I then realized that while trying to solve an earlier problem I had added the $env:ProgramFiles\WindowsPowerShell\Modules
directory to the PSModulePath
environment variable, so the modules were being duplicated and causing problems. After removing the path from the PSModulePath
environment variable, everything works!