Powershell 设置DSC拉取服务器时出错
我正在尝试设置Powershell DSC拉取服务器。我已将xPSDesiredStateConfiguration DSC模块复制到C:\Windows\System32\WindowsPowerShell\v1.0\Modules 当我尝试运行下面的dsc脚本时:Powershell 设置DSC拉取服务器时出错,powershell,dsc,Powershell,Dsc,我正在尝试设置Powershell DSC拉取服务器。我已将xPSDesiredStateConfiguration DSC模块复制到C:\Windows\System32\WindowsPowerShell\v1.0\Modules 当我尝试运行下面的dsc脚本时: configuration CreatePullServe1r { param ( [string[]]$ComputerName = 'localhost' ) Import-DSCResource -
configuration CreatePullServe1r
{
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
我收到以下错误消息:
At line:1 char:15
+ configuration CreatePullServe1r
+ ~~~~~~~~~~~~~~~~~
System.IO.DirectoryNotFoundException: Could not find a part of the path
'C:\Windows\system32\WindowsPowershell\v1.0\Modules\PSDesiredStateConfiguration\PSProviders'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption
searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.EnumerateDirectories(String path)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.Initialize(Collection`1 errors)
at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Dictionary`2 functionsToDefine,
Collection`1 errors)
at System.Management.Automation.Language.Parser.ConfigurationStatementRule(Token configurationToken)
At line:2 char:1
+ {
+ ~
Unexpected token '{' in expression or statement.
At line:45 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ParserError
如果我有任何错误,请告诉我。首先,您在第一行将配置名称拼写错误 “配置CreatePullServe1r” 最后运行
CreatePullServer
(末尾没有1)
但是没有,此DSC配置在我的计算机上运行良好,您必须有服务器本地的问题,并且很可能通过清除缓存或重新启动WMI服务来修复