WMF5.1 之后 DSC 环境资源不再起作用 - 未检测 PATH 值?

WMF5.1 之后 DSC 环境资源不再起作用 - 未检测 PATH 值?

我有许多部分 DSC 脚本使用环境资源来设置路径值。我有两个脚本执行此操作,从 WMF5.0 升级到 WMF5.1 后,启动 DscConfigurations 时出现以下错误。

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ApplyConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer MYCOMPUTER with user sid S-1-5-21-1064954374-356710528-937385128-34335.
VERBOSE: [DESTCOMPUTER]:                            [] Starting consistency engine.
The resources ('[Environment]SetInstantClientPath' and '[Environment]SqlCmdPath') have conflicting values of the following properties: 'Value'. Ensure that their values match.  Merging of partial configurations failed. LCM 
failed to start desired state configuration manually.
    + CategoryInfo          : ResourceExists: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 11
    + PSComputerName        : DESTCOMPUTER

有一个脚本这样做:

Environment SqlCmdPath {
    Name = "Path"
    DependsOn = "[Package]InstallSQLServer2012CmdLineUtils_64bit"
    Ensure = "Present"
    Path = $true
    Value = "$env:ProgramFiles\Microsoft SQL Server\110\Tools\Binn"
}

另一个脚本执行以下操作:

Environment SetInstantClientPath {
    Name = "Path"
    DependsOn = "[Archive]InstallInstantClientBasic","[Archive]InstallInstantClientSqlplus"
    Ensure = "Present"
    Path = $true
    Value = "$env:SystemDrive\instantclient_11_2"
}

这曾经在 WMF5.0 中顺利运行

自 WMF5.1 以来有什么变化吗?

答案1

您有两个环境资源(变量),它们具有相同的 Name 参数值。当引擎创建环境变量时,这可能会导致冲突。我建议您将其更改为以下内容:

Environment SqlCmdPath {
    Name = "SqlCmdPath"
    DependsOn = "[Package]InstallSQLServer2012CmdLineUtils_64bit"
    Ensure = "Present"
    Path = $true
    Value = "$env:ProgramFiles\Microsoft SQL Server\110\Tools\Binn"
}
Environment SetInstantClientPath {
    Name = "SetInstantClientPath"
    DependsOn = "[Archive]InstallInstantClientBasic","[Archive]InstallInstantClientSqlplus"
    Ensure = "Present"
    Path = $true
    Value = "$env:SystemDrive\instantclient_11_2"
}

https://msdn.microsoft.com/en-us/powershell/dsc/environmentresource

只是一个快速更新,但目前微软有一个关于这个确切问题的请求......

https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088876-dsc-environment-resource-does-not-allow-duplicate

相关内容