我正在阅读 powershell.org 的 DSC 书籍,并尝试使用书中指定的配置代码设置拉取服务器。
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 模块。
Import-DSCResource -ModuleName xPSDesiredStateConfiguration 无法加载模块“xPSDesiredStateConfiguration”:找不到模块。
我确认我已经安装了 DSC 资源工具包,并且在我执行 Get-DSCResource 命令时会列出该模块。谁能告诉我我可能做错了什么?
另外,我使用的是 64 位 Windows 7 并安装了 KB2819745 以将 powershell 升级到版本 4。