重大变更:用于DSC配置中密码加密/解密的证书在安装WMF 5.0 RTM后可能无法正常工作
在 WMF 4.0 和 WMF 5.0 预览版中,DSC 不允许配置中的密码长度超过 121 字符。 DSC强制使用简短密码,即使希望密码更长且强。 这一突破性变更允许密码在DSC配置中任意长度。
分辨率: 重新创建证书,使用数据加密或密钥加密密钥使用,以及文档加密增强密钥使用(1.3.6.1.4.1.311.80.1)。 更多信息请参见 Protect-CmsMessage。
安装 WMF 5.0 RTM 后,DSC 指令小程序可能会失败
Start-DscConfiguration 其他 DSC 指令小组件在安装 WMF 5.0 RTM 后可能会因以下错误而失败:
LCM failed to retrieve the property PendingJobStep from the object of class dscInternalCache .
+ CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 6
+ PSComputerName : localhost
分辨率: 通过在提升权限的PowerShell会话中执行以下命令(以管理员身份运行)删除DSCEngineCache.mof:
Remove-Item -Path $env:SystemRoot\system32\Configuration\DSCEngineCache.mof
如果在 WMF 5.0 生产预览之上安装了 WMF 5.0 RTM,DSC 指令小块可能无法使用
分辨率: 在提升的PowerShell会话中执行以下命令(以管理员身份运行):
mofcomp $env:windir\system32\wbem\DscCoreConfProv.mof
在调试模式下使用 Get-DscConfiguration 时,LCM可能会进入不稳定状态
如果LCM处于调试模式,按CTRL+C停止处理, Get-DscConfiguration 可能导致LCM进入不稳定状态,导致大多数DSC指令符无法工作。
分辨率: 调试 cmdlet 时不要按 CTRL+C Get-DscConfiguration 。
Stop-DscConfiguration 在调试模式下可能无法响应
如果LCM处于调试模式, Stop-DscConfiguration 在尝试停止由 Get-DscConfiguration
分辨率:按照《调试DSC资源》中所述,完成从作Get-DscConfiguration开始的调试。
调试模式中不显示冗长错误消息
如果LCM处于 调试模式,DSC资源不会显示冗长错误信息。
分辨率: 禁用 调试模式 以查看资源中的冗长消息
Invoke-DscResource作无法被 Get-DscConfigurationStatus cmdlet 检索到
使用 Invoke-DscResource cmdlet直接调用任意资源的方法后,无法通过 Get-DscConfigurationStatus检索该作的记录。
分辨率: 没有。
Get-DscConfigurationStatus 返回拉取循环作,类型 为一致性
当节点设置为 PULL 刷新模式时,每次执行拉取作时, Get-DscConfigurationStatus cmdlet 会将作类型报告为 一致性(Consistency ),而非 初始(Initial)
分辨率: 没有。
Invoke-DscResource cmdlet 不会按生成顺序返回消息
Invoke-DscResource该命令包不会按LCM或DSC资源生成的顺序返回冗长、警告和错误消息。
分辨率: 没有。
DSC 资源在与 Invoke-DscResource 一起使用时无法轻易调试
当 LCM 以调试模式运行时, Invoke-DscResource cmdlet 不会提供用于调试所需的运行空间信息。 更多信息请参见 调试DSC资源。
分辨率: 使用 cmdlets Get-PSHostProcessInfo, Enter-PSHostProcess , 发现 Get-Runspace 并附加到运行空间,并 Debug-Runspace 调试 DSC 资源。
# Find all the processes hosting PowerShell
Get-PSHostProcessInfo
ProcessName ProcessId AppDomainName
----------- --------- -------------
powershell 3932 DefaultAppDomain
powershell_ise 2304 DefaultAppDomain
WmiPrvSE 3396 DscPsPluginWkr_AppDomain
# Enter the process that is hosting DSC engine (WMI process with DscPsPluginWkr_Appdomain)
Enter-PSHostProcess -Id 3396 -AppDomainName DscPsPluginWkr_AppDomain
# Find all the available rusnspaces in that process
Get-Runspace
Id Name ComputerName Type State Availability
-- ---- ------------ ---- ----- ------------
2 Runspace2 localhost Local Opened InBreakpoint
5 RemoteHost localhost Local Opened Busy
# Debug the runspace that is in **InBreakpoint** availability state
Debug-Runspace -Id 2
同一节点的各种部分配置文档不能有相同的资源名称
对于部署到单一节点的多个部分配置,资源名称相同会导致运行时错误。
分辨率: 即使是相同的资源,在不同部分配置中也要用不同的名称。
Start-DscConfiguration – UseExisting不支持 -Credential
使用Start-DscConfigurationUseExistant参数时,Credential参数被忽略。 DSC使用默认进程身份来执行作。 当需要使用不同的凭证才能在远端节点继续时,这会导致错误。
分辨率: 使用CIM会话进行远程DSC作:
$session = New-CimSession -ComputerName $node -Credential $credential
Start-DscConfiguration -UseExisting -CimSession $session
DSC配置中的IPv6地址作为节点名
本版本不支持在DSC配置脚本中将IPv6地址作为节点名。
分辨率: 没有。
DSC资源调试Class-Based
本版本不支持基于类的 DSC 资源调试。
分辨率: 没有。
在 DSC Class-Based 资源中定义$script变量和函数不会在多次调用 DSC 资源时保持不变
如果配置使用任何基于类且作用域中定义$script了变量或函数的资源,连续多次调用Start-DSCConfiguration失败。
分辨率: 定义 DSC 资源类中的所有变量和函数。 没有 $script 作用域变量/函数。
当资源使用 PSDscRunAsCredential 时的 DSC 资源调试
本版本不支持当资源在配置中使用 PSDscRunAsCredential 属性时进行DSC资源调试。
分辨率: 没有。
PSDSCRunAs凭证不支持DSC复合资源
分辨率: 如果有,请使用Credential属性。 示例服务集和WindowsFeatureSet
Get-DscResource -Syntax 未正确反映 PsDscRunAsCredential
当资源将 PsDscRunAsCredential 标记为强制或不支持时,语法参数并未正确反映。
分辨率: 没有。 然而,在使用 IntelliSense 时,ISE 中的创作配置会反映关于 PsDscRunAsCredential 属性的正确元数据。
WindowsOptionalFeature 在 Windows 7 中不可用
WindowsOptionalFeature DSC 资源在 Windows 7 中不可用。 该资源需要 DISM 模块和从 Windows 8 及更新版本开始可用的 DISM 指令小工具。
对于基于类别的DSC资源,Import-DscResource -ModuleVersion 可能无法如预期般工作
如果编译节点有多个基于类的 DSC 资源模块版本, Import-DscResource -ModuleVersion 则未选择指定版本,导致编译错误。
ImportClassResourcesFromModule : Exception calling "ImportClassResourcesFromModule" with "3" argument(s):
"Keyword 'MyTestResource' already defined in the configuration."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2035 char:35
+ ... rcesFound = ImportClassResourcesFromModule -Module $mod -Resources $r ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ImportClassResourcesFromModule], MethodInvocationException
+ FullyQualifiedErrorId : PSInvalidOperationException,ImportClassResourcesFromModule
分辨率: 通过将 ModuleSpecification 对象定义为 ModuleName 参数,并指定 RequiredVersion 键,导入所需版本:
Import-DscResource -ModuleName @{ModuleName='MyModuleName';RequiredVersion='1.2'}
一些DSC资源,比如注册资源,处理请求可能会开始花费较长时间。
决心一: 创建一个计划任务,定期清理下一个文件夹。
$env:windir\system32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\CommandAnalysis
决议二: 更改DSC配置以清理配置末尾的 CommandAnalysis 文件夹。
Configuration $configName
{
# User Data
Registry SetRegisteredOwner
{
Ensure = 'Present'
Force = $True
Key = $Node.RegisteredKey
ValueName = $Node.RegisteredOwnerValue
ValueType = 'String'
ValueData = $Node.RegisteredOwnerData
}
#
# Script to delete the config
#
script DeleteCommandAnalysisCache
{
DependsOn = "[Registry]SetRegisteredOwner"
getscript = "@{}"
testscript = 'Remove-Item -Path $env:windir\system32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\CommandAnalysis -Force -Recurse -ErrorAction SilentlyContinue -ErrorVariable ev | out-null;$true'
setscript = '$true'
}
}