gpt4 book ai didi

Powershell DSC : Unable to load module xPSDesiredStateConfiguration

转载 作者:行者123 更新时间:2023-12-04 14:12:29 27 4
gpt4 key购买 nike

我正在阅读 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 Unable to load module 'xPSDesiredStateConfiguration': module not found.



我确认我已安装 DSC 资源工具包,并且在我执行 Get-DSCResource 命令时会列出该模块。谁能告诉我我可能做错了什么?

另外,我使用的是 64 位 Windows 7 并安装了 KB2819745 以将 powershell 升级到版本 4。

最佳答案

首先,您需要安装软件包。你可以在这里下载:
https://gallery.technet.microsoft.com/xPSDesiredStateConfiguratio-417dc71d

关于Powershell DSC : Unable to load module xPSDesiredStateConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26162956/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com