Windows PowerShell 預期狀態設定概觀Windows PowerShell Desired State Configuration Overview

適用於:Windows PowerShell 4.0、Windows PowerShell 5.0Applies To: Windows PowerShell 4.0, Windows PowerShell 5.0

DSC 是 PowerShell 中的管理平台,可讓您以程式碼形式的設定來管理 IT 和開發基礎結構。DSC is a management platform in PowerShell that enables you to manage your IT and development infrastructure with configuration as code.

重要概念Key Concepts

DSC 是用於設定、部署和管理系統的宣告式平台。DSC is a declarative platform used for configuration, deployment, and management of systems. 它包含三個主要元件:It consists of three primary components:

  • 設定 是宣告式 PowerShell 指令碼,會定義和設定資源的執行個體。Configurations are declarative PowerShell scripts which define and configure instances of resources. 在執行設定時,DSC (及設定所呼叫的資源) 將只會「保持原狀」,確保系統存在於設定所配置的狀態。Upon running the configuration, DSC (and the resources being called by the configuration) will simply “make it so”, ensuring that the system exists in the state laid out by the configuration. DSC 設定也是等冪:本機設定管理員 (LCM) 仍可確定電腦依據設定中宣告的任何狀態所設定。DSC configurations are also idempotent: the Local Configuration Manager (LCM) will continue to ensure that machines are configured in whatever state the configuration declares.
  • 資源是 DSC「實現目標狀態」的方式。Resources are the "make it so" part of DSC. 它們包含的程式碼可使設定的目標進入並保持在指定狀態。They contain the code that put and keep the target of a configuration in the specified state. 資源位於 PowerShell 模組,且可以被撰寫以針對檔案或 Windows 處理序等一般項目建立模型,或是針對 IIS 伺服器或 Azure 中執行的 VM 等特定項目建立模型。Resources reside in PowerShell modules and can be written to model something as generic as a file or a Windows process, or as specific as an IIS server or a VM running in Azure.
  • 本機設定管理員 (LCM) 是 DSC 用於協助資源和設定之間互動的引擎。The Local Configuration Manager (LCM) is the engine by which DSC facilitates the interaction between resources and configurations. LCM 使用資源所實作的控制流程,定期輪詢系統,以確保能維持設定所定義的狀態。The LCM regularly polls the system using the control flow implemented by resources to ensure that the state defined by a configuration is maintained. 如果系統未符合狀態,LCM 會呼叫資源內的程式碼,以根據設定來「實現目標狀態」。If the system is out of state, the LCM makes calls to the code in resources to “make it so” according to the configuration.

另請參閱See Also