microsoft / microsoft/winget-cli

winget configure fails when calling WindowsOptionalFeature DSC Resource

Open
#4,264 11 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Command-Configure DSC-Resource Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

When a winget configuration calls the DSC resource PSDscResources/WindowsOptionalFeature it will error with with message Class not registered

Steps to reproduce

Author a configuration with the following resource:

  - resource: PSDscResources/WindowsOptionalFeature
    id: removeWindowsMediaPlayer
    directives:
      description: Uninstall Windows Media removeWindowsMediaPlayer
    settings:
      name: WindowsMediaPlayer
      ensure: Absent 
Expected behavior

Configuration succeeds and the optional feature is removed.

Actual behavior

Errors with Class not registered

image

From the winget logs this is happening on line 286 of the DSC resource
image

image

When running the same command in PowerShell the command succeeds without error:
image

Is winget using a different version of Dism than the PowerShell module is?

This happens on Windows 10 and Windows 11, PowerShell version 5.1 or 7.4

Environment
Windows Package Manager v1.7.10582
Windows: Windows.Desktop v10.0.22631.3296
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.10582.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided winget configuration using PSDscResources/WindowsOptionalFeature and compare it with the equivalent PowerShell command. Start from the winget logs around line 286 of the DSC resource and investigate the configuration path that invokes it. Done means the optional feature is removed successfully without the Class not registered error on the reported Windows versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.