預期狀態設定 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 參數,或者您可以安裝第 3 版(或更新版本)PSDesireStateConfiguration,其中包含重大差異。
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 組態區塊中使用認證
- 搭配 DSC 組態使用 ConfigurationData 參數
- 在 DSC 組態中使用
Node
關鍵詞 - 使用複合 DSC 組態 (將另一個 DSC 組態巢狀於其中之 DSC 組態的 DSC 組態)
已移除內建 DSC 資源。 PSDscResources 模組包含部分已移除 DSC 資源的取代專案。 如需 DSC 資源的狀態,請參閱下表。
DSC 資源 | 地位 |
---|---|
Archive |
由 PSDscResources 中封存 DSC 資源取代。 |
Environment |
由 PSDscResources 中的環境 DSC 資源取代。 |
File |
刪除。 DSC v2 和更新版本中無法使用此 DSC 資源。 |
Group |
取代為 PSDscResources 中群組 DSC 資源。 |
GroupSet |
由 PSDscResources 中的GroupSet DSC 資源取代。 |
Log |
刪除。 DSC v2 和更新版本中無法使用此 DSC 資源。 |
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 v2 和更新版本中無法使用此 DSC 資源。 |
WaitForAny |
刪除。 DSC v2 和更新版本中無法使用此 DSC 資源。 |
WaitForSome |
刪除。 DSC v2 和更新版本中無法使用此 DSC 資源。 |
WindowsFeature |
以 PSDscResources 中WindowsFeature DSC 資源取代。 |
WindowsFeatureSet |
取代為 PSDscResources 中WindowsFeatureSet DSC 資源。 |
WindowsOptionalFeature |
由 PSDscResources 中的WindowsOptionalFeature DSC 資源取代。 |
WindowsOptionalFeatureSet |
取代為 PSDscResources 中的WindowsOptionalFeatureSet DSC 資源。 |
WindowsPackageCab |
由 PSDscResources 中的WindowsPackageCab DSC 資源取代。 |
WindowsProcess |
由 PSDscResources 中的WindowsProcess DSC 資源取代。 |