我正在通过powershell.org的DSC书,并尝试使用本书中指定的配置代码设置拉服务器。Powershell DSC:无法加载模块xPSDesiredStateConfiguration
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
当我运行配置脚本,PowerShell的报告,它是无法加载xPSDesiredStateConfiguration模块。
进口DSCResource -ModuleName xPSDesiredStateConfiguration无法 加载模块 'xPSDesiredStateConfiguration':模块未找到。
我确认已安装了DSC资源工具包,并且在执行Get-DSCResource命令时列出了该模块。任何人都可以给我一个线索,说明我可能做错了什么?
此外,我使用的是Windows 7,并且已安装KB2819745把PowerShell的最高版本为4
是您系统上的模块吗? Get-Module -ListAvailible – Schwarzie2478 2014-10-02 14:51:17
是的,它被列出。 尽管您的建议确实使我走上了解决方案的道路。我注意到当我运行Get-Module-ListAvailable命令时,它列出了包含该模块两次的目录。在试图解决早期问题时,我已经将$ env:ProgramFiles \ WindowsPowerShell \ Modules目录添加到PSModulePath环境变量中,因此模块以某种方式被复制。看来这是造成这个问题的原因,因为它在我从PSModulePath环境变量中删除目录后工作。 – Domin 2014-10-02 15:05:55