Desired State Configuration 2.0
随着 PowerShell 7.2 的发布,PSDesiredStateConfiguration 模块不再包含在 PowerShell 包中。 将 DSC 分离到自己的模块后,我们可以独立于 PowerShell 投资和开发 DSC,并减小 PowerShell 包的大小。 DSC 的用户无需升级 PowerShell 即可享受升级 DSC 的好处,从而缩短部署新的 DSC 功能的时间。 想要继续使用 DSC v2 的用户可以从 PowerShell 库下载 PSDesiredStateConfiguration 2.0.7。
使用非 Windows 环境的用户可能需要 DSC v3 中的跨平台功能。 有关 DSC 的未来的详细信息,请参阅 PowerShell 团队博客。
若要从 PowerShell 库安装 PSDesiredStateConfiguration 2.0.7:
Install-Module -Name PSDesiredStateConfiguration -Repository PSGallery -MaximumVersion 2.99
重要
请务必包括 maximumVersion 参数,或者可以安装 PSDesireStateConfiguration 版本 3(或更高版本),其中包含重大差异。
DSC 2.0 用例
DSC 2.0 支持与 Azure 计算机配置配合使用。 其他方案(如直接调用具有 Invoke-DscResource
的 DSC 资源)可能正常运行,但不是此版本的主要用途。
如果不使用 Azure 计算机配置,则应使用 DSC 1.1.machine
DSC 1.1 中的更改
DSC 2.0 中有几个重大更改。
在 2.0 中使用 DSC 资源的唯一方法是使用 Invoke-DscResource
cmdlet 或 Azure 计算机配置。
已删除以下 cmdlet:
Disable-DscDebug
Enable-DscDebug
Get-DscConfiguration
Get-DscConfigurationStatus
Get-DscLocalConfigurationManager
Publish-DscConfiguration
Remove-DscConfigurationDocument
Restore-DscConfiguration
Set-DscLocalConfigurationManager
Start-DscConfiguration
Stop-DscConfiguration
Test-DscConfiguration
Update-DscConfiguration
已删除以下功能:
- 请求服务器
- 本地配置管理器 (LCM)
不支持以下功能:
- 多系统 DSC 配置
- 跨系统依赖项(
WaitFor*
DSC 资源) - DSC 资源的重新启动行为
- 将参数添加到 DSC 配置块
- 在 DSC 配置块中使用流控制语句
- 在 DSC 配置块中使用凭据
- 将 ConfigurationData 参数与 DSC 配置配合使用
- 在 DSC 配置中使用
Node
关键字 - 使用复合 DSC 配置(在其中嵌套另一个 DSC 配置的 DSC 配置)
已删除内置 DSC 资源。 PSDscResources 模块包括某些已删除 DSC 资源的替换项。 有关 DSC 资源的状态,请参阅下表。
DSC 资源 | 地位 |
---|---|
Archive |
替换为 PSDscResources 中的存档 DSC 资源。 |
Environment |
替换为 PSDscResources 中的Environment DSC 资源。 |
File |
删除。 此 DSC 资源在 DSC v2 及更高版本中不可用。 |
Group |
由 PSDscResources 中的组 DSC 资源替换。 |
GroupSet |
替换为 PSDscResources 中的GroupSet DSC 资源。 |
Log |
删除。 此 DSC 资源在 DSC v2 及更高版本中不可用。 |
Package |
部分替换为 PSDscResources 中的MsiPackage DSC 资源。 |
ProcessSet |
替换为 PSDscResources 中的ProcessSet DSC 资源。 |
Registry |
替换为 PSDscResources 中的注册表 DSC 资源。 |
Script |
替换为 PSDscResources 中的脚本 DSC 资源。 |
Service |
替换为 PSDscResources 中的服务 DSC 资源。 |
ServiceSet |
替换为 PSDscResources 中的ServiceSet DSC 资源。 |
User |
替换为 PSDscResources 中的User DSC 资源。 |
WaitForAll |
删除。 此 DSC 资源在 DSC v2 及更高版本中不可用。 |
WaitForAny |
删除。 此 DSC 资源在 DSC v2 及更高版本中不可用。 |
WaitForSome |
删除。 此 DSC 资源在 DSC v2 及更高版本中不可用。 |
WindowsFeature |
替换为 PSDscResources 中的WindowsFeature DSC 资源。 |
WindowsFeatureSet |
替换为 PSDscResources 中的WindowsFeatureSet DSC 资源。 |
WindowsOptionalFeature |
替换为 PSDscResources 中的WindowsOptionalFeature DSC 资源。 |
WindowsOptionalFeatureSet |
替换为 PSDscResources 中的WindowsOptionalFeatureSet DSC 资源。 |
WindowsPackageCab |
替换为 PSDscResources 中的WindowsPackageCab DSC 资源。 |
WindowsProcess |
替换为 PSDscResources 中的WindowsProcess DSC 资源。 |