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.
Installing DSC Resources using PowerShellGet To install a DSC resource, use the Install-Module cmdlet, specifying the name of the module shown under Module name in your search results. The "TimeZone" resource exists in the "ComputerManagementDSC" module, so that is the module this example installs.
Get-DscResource. Gets Desired State Configuration (DSC) resources present on the computer. Invoke-DscResource. Runs a method of a specified PowerShell Desired State Configuration (DSC) resource.
Desired State Configuration (DSC) is a feature in PowerShell 4.0 and above that helps administrators to automate the configuration of Windows and Linux operating systems (OSes). DSC provides a set of PowerShell language extensions, cmdlets and a process called declarative scripting.
Desired State Configuration (DSC) Resources provide the building blocks for a DSC configuration. A resource exposes properties that can be configured (schema) and contains the PowerShell script functions that the Local Configuration Manager (LCM) calls to "make it so".
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With