Powershell DSC: Unable to load xPSDesiredStateConfiguration module

I work through a DSC book from powershell.org and try to configure a push 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 script configuration, powershell reports that it cannot load the xPSDesiredStateConfiguration module.

Import-DSCResource -ModuleName xPSDesiredStateConfiguration Unable to load module 'xPSDesiredStateConfiguration': module not found.

I confirmed that I have a DSC resource set installed and the module is specified when I execute the Get-DSCResource command. Can someone let me know what I may have done wrong?

In addition, I am using the 64-bit version of Windows 7 and installed KB2819745 to port powershell to version 4.

+6
source share
1 answer

Responding to a comment on my original question, I checked that the module was specified when executing Get-Module -ListAvailable . I noticed that when I ran the command, it listed the directory containing the module twice . Then I realized that in an attempt to solve an earlier problem, I added the $env:ProgramFiles\WindowsPowerShell\Modules PSModulePath environment PSModulePath , so the modules were duplicated and cause problems. After removing the path from the PSModulePath environment PSModulePath everything works!

+9
source

Source: https://habr.com/ru/post/976153/


All Articles