What is DSC?
Desired State Configuration (DSC) is a declarative platform for configuring Windows systems. Instead of writing imperative scripts, you declare the desired state of your system, and DSC ensures that state is achieved and maintained.WinGet DSC Resources
TheMicrosoft.WinGet.DSC module provides five DSC resources:
WinGetPackage
Manage package installation state
WinGetSource
Manage package sources
WinGetUserSettings
Configure user settings
WinGetAdminSettings
Configure admin settings
WinGetPackageManager
Ensure WinGet is installed
Installation
Install the DSC module from PowerShell Gallery:Using DSC Resources
DSC resources can be used in two ways:1. Configuration Files (Recommended)
Define resources in YAML configuration files:2. PowerShell DSC Configuration
Use resources in PowerShell DSC configurations:Resource: WinGetPackage
Manages the installation state of packages.Properties
The package identifier (key property).
The source name (key property).
The specific version to install.
Whether the package should be Present or Absent.
How to match the package ID: Equals, EqualsCaseInsensitive, StartsWithCaseInsensitive, ContainsCaseInsensitive.
Always keep the package updated to the latest version.
Installation mode: Default, Silent, Interactive.
Example
Resource: WinGetSource
Manages package sources.Properties
The source name (key property).
The source URL or argument.
The source type (e.g., “Microsoft.PreIndexed.Package”).
Trust level: Undefined, None, Trusted.
Whether the source requires explicit selection.
The source priority.
Whether the source should be Present or Absent.
Example
Resource: WinGetUserSettings
Manages WinGet user settings.Properties
User identifier (key property, do not set manually).
Hashtable of settings to configure.
Full (replace all settings) or Partial (merge with existing).
Example
Resource: WinGetAdminSettings
Manages WinGet administrator settings (requires admin privileges).Properties
System identifier (key property, do not set manually).
Hashtable of admin settings to configure.
Example
Resource: WinGetPackageManager
Ensures WinGet is installed and optionally at a specific version.Properties
System identifier (key property, do not set manually).
Specific version to install.
Install the latest stable version.
Install the latest pre-release version.
Example
Complete Configuration Example
Testing DSC Resources
Test if the system is in the desired state:Best Practices
- Use Configuration Files: Prefer YAML configuration files over PowerShell DSC scripts
- Version Control: Store configuration files in version control
- Test First: Test configurations in development before production
- Idempotent: DSC resources are idempotent - safe to run multiple times
- Admin Rights: Some resources (WinGetAdminSettings, WinGetSource) require admin privileges
- UseLatest: Use
useLatest: truefor packages that should stay current
Next Steps
DSC Resources Reference
Detailed reference for all DSC resources
Configuration Overview
Learn about configuration files
Getting Started
Get started with WinGet PowerShell