In addition to installing app packages from the repository, you can use the WinGet package manager for declarative Windows environment configuration. The idea is that the administrator creates a declarative YAML file describing the desired state of the computer, including Windows settings and required software. Then, WinGet uses PowerShell Desired State Configuration (DSC) to automatically configure Windows to the specified state defined in the YAML file.
The winget configure command uses PowerShell Desired State Configuration (DSC) 3.0, including the newer Microsoft DSC 3 architecture, to automatically configure Windows to the desired state defined in the configuration file. The YAML configuration file declaratively describes the required system state, including program installations or removals with their versions, Windows features and roles to add or remove, and the necessary Windows and application settings. Applying this YAML file will automate the deployment of the environment on a Windows workstation or server.
Now, let’s take a look at a simple YAML configuration file for Winget. My sample configuration used to install several apps (Firefox, Notepad++, and PowerToys) and remove 7-Zip if it is installed. It also makes changes to the registry (enables Windows registry backup using the EnablePeriodicBackup option).
winget show powertoys -s msstore
The command to find app package names in Winget:
winget search appname
or among installed apps:
winget list
You can find a sample of such a YAML file in our GitHub repository https://github.com/maxbakhub/winposh/blob/main/DSC/winget_configure_dsc_sample_win11.yaml
Now, let’s try to apply the configuration from this YAML file via winget configure. First, enable DSC support in WinGet:
winget configure --enable
Before applying the DSC configuration, it is recommended to validate the syntax of the YAML file.
winget configure validate winget_configure_dsc_sample_win11.yaml
Now, apply the configuration from the YAML file to the computer.
winget configure --file winget_configure_dsc_sample_win11.yaml --accept-configuration-agreements
WinGet reads the settings from the YAML file, installs/removes the described apps, and applies the specified Windows settings (the ConfigurationRemotingServer.exe process parses the YAML file and applies the settings). Thus, with just one command, you get a fully configured Windows environment. A detailed log of the applied DSC settings will appear on the screen.
Perform a dry run to see how your computer’s current configuration matches the YAML file.
winget configure test -f winget_configure_dsc_sample_win11.yaml --accept-configuration-agreements
For all items that do not match the desired configuration, the command will return:
System is not in the described configuration state.
When you reapply the YAML configuration file, Winget Configure will only apply changes that differ from the desired configuration.
securityContext: elevated directive means that a one-time User Account Control (UAC) elevation prompt is required to apply certain system configuration settings.With WinGet, you can specify a YAML configuration file located on an external webpage as the source for configuration (this allows the deployment of the desired state configurations to be automated via GitHub/GitLab).
winget configure --accept-configuration-agreements --disable-interactivity -f https://raw.githubusercontent.com/maxbakhub/winposh/refs/heads/main/DSC/winget_configure_dsc_sample_win11.yaml
WinGet allows administrators to configure Windows machines to a specific state using declarative YAML files, ensuring configuration idempotency and supporting the Infrastructure as Code (IaC) approach to Windows environment management. WinGet with DSC lets you implement an Ansible-playbook equivalent for Windows devices, enabling declarative, automated configuration management.





