Inicio Information Technology Utilizing Desired State Configuration (DSC) v3 on Home windows Server 2025

Utilizing Desired State Configuration (DSC) v3 on Home windows Server 2025

0
Utilizing Desired State Configuration (DSC) v3 on Home windows Server 2025


Microsoft Desired State Configuration v3 has some substantive modifications in comparison with earlier variations of the know-how. In contrast to PowerShell Desired State Configuration (PSDSC) v1.1 and v2, DSC v3 operates as a standalone command somewhat than a service, eliminating the necessity for an area configuration supervisor. This architectural change makes DSC v3 simpler to make use of and scale, permitting any software that may execute instructions on Home windows Server, corresponding to Scheduled Duties, to use DSC configurations.

For this doc:

  • DSC refers to Desired State Configuration v3.0.0
  • PSDSC refers to PowerShell Desired State Configuration (PSDSC) v1.1 and v2

You possibly can set up DSC utilizing WinGet. Home windows Server 2025 contains built-in help for WinGet, making the set up course of extra simple than on earlier server variations. Nonetheless, it is necessary to notice that winget is barely obtainable for Home windows Server 2025 with Desktop Expertise and may’t be used with Server Core deployments.

DSC v3 requires PowerShell 7.2 or later. As Home windows Server 2025 comes with Home windows PowerShell 5.1, you will want to put in PowerShell 7.x individually, which you are able to do manually or utilizing WinGet from an elevated PowerShell session.

winget set up microsoft.powershell

The PSDesiredStateConfiguration module specifies a minimal PowerShell model of seven.2 in its module manifest.

WinGet supplies probably the most simple set up expertise with automated updates:

  1. Open PowerShell with administrative privileges
  2. Seek for the DSC package deal utilizing:
winget search DesiredStateConfiguration

  1. Set up the steady model utilizing:
winget set up --id 9NVTPZWRC6KQ --source msstore

Alternatively, obtain the most recent launch from the PowerShell/DSC repository and add the folder containing the expanded archive contents to your PATH surroundings variable.

Primary DSC v3 Instructions

To view all obtainable instructions in DSC v3, use:

dsc --help

The output will show obtainable instructions together with:

  • completer – Generate a shell completion script
  • config – Apply a configuration doc
  • useful resource – Invoke a selected DSC useful resource
  • schema – Get the JSON schema for a DSC kind
  • assist – Show assist data for instructions

To see the assets obtainable to be used in configurations:

dsc useful resource listing

This command shows all DSC assets put in in your system that can be utilized in configuration paperwork.

Creating DSC v3 Configurations

DSC v3 configurations may be written in YAML format, which is extra concise and readable than the MOF format utilized in earlier variations.

A DSC v3 configuration doc should embrace:

  1. A reference to the DSC useful resource schema
  2. At the least one useful resource definition with properties

Making a Primary Configuration

This is an instance of a fundamental configuration in YAML format:

$schema: https://uncooked.githubusercontent.com/PowerShell/DSC/essential/schemas/2023/08/config/doc.json
assets:
  - identify: Power icon view in Management Panel
    kind: Microsoft.Home windows/Registry
    properties:
      keyPath: HKCUSOFTWAREMicrosoftWindowsCurrentVersionPoliciesExplorer
      valueName: ForceClassicControlPanel
      valueData:
        DWord: 1

This configuration units a registry worth to pressure the Management Panel to show utilizing the traditional icon view.

For compatibility with traditional PowerShell assets, you should use the WindowsPowerShell useful resource kind:

$schema: https://uncooked.githubusercontent.com/PowerShell/DSC/essential/schemas/2024/04/config/doc.json
metadata:
  identify: IIS-Configuration
assets:
  - identify: Use Home windows PowerShell assets
    kind: Microsoft.Home windows/WindowsPowerShell
    properties:
      assets:
        - identify: Internet server set up
          kind: PSDesiredStateConfiguration/WindowsFeature
          properties:
            Title: Internet-Server
            Guarantee: Current

This configuration makes use of the traditional WindowsFeature useful resource from the PSDesiredStateConfiguration module to put in IIS.

As soon as you’ve got created a configuration doc, you possibly can check and apply it utilizing DSC v3 instructions.

To check a configuration to see what modifications can be made (somewhat than shouting Cowabunga on manufacturing techniques) run the next command:

dsc config get -f .iis-config.yaml

This command assesses the present state with out making modifications, exhibiting what would occur if you happen to utilized the configuration.

To use a configuration run a model of the command (along with your yaml file specified):

dsc config set -f .iis-config.yaml

This command applies the configuration outlined within the YAML file to your system.

You’ll find out extra about DSC v3 on the following areas:

https://devblogs.microsoft.com/powershell/get-started-with-dsc-v3/     

https://github.com/PowerShell/PSDesiredStateConfiguration

https://learn.microsoft.com/powershell/dsc/overview?view=dsc-3.0&preserveView=true    

https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.5 

DEJA UNA RESPUESTA

Por favor ingrese su comentario!
Por favor ingrese su nombre aquí