Open jcwalker opened 7 months ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
I ran into this same problem with the Windows Sandbox. It looks like it's happening to the way the DISM APIs are being called. We recently refactored our WinGet dependency feature to call DISM directly.
I did find a bit of a workaround by using the Microsoft.WinGet.Configuration module (requires PowerShell 7).
@denelon thanks for the quick reply! I can confirm that workaround work.
I am getting the same error when using this YAML:
properties:
resources:
- resource: PSDscResources/WindowsOptionalFeature
settings:
name: VirtualMachinePlatform
ensure: Present
Error in the log file:
2024-04-02 15:56:41.341 [CONF] Microsoft.Management.Configuration.Processor.Exceptions.InvokeDscResourceException: Failed when calling `Test` for resource: WindowsOptionalFeature [PSDscResources] Message: 'Class not registered '
It appears @denelon's workaround does work, but using winget configure
to install PowerShell 7 on a fresh machine beforehand is a bit of a pain.
As a side note, it seems that installing and setting up WSL is a very common use case for winget configure
, which currently requires multiple steps in the YAML file to get working (enable Windows Virtual Machine Platform, install WSL, install desired Linux distro). It would be great if there was a DSC module which just does all this for you.
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:
Expected behavior
Configuration succeeds and the optional feature is removed.
Actual behavior
Errors with
Class not registered
From the winget logs this is happening on line 286 of the DSC resource
When running the same command in PowerShell the command succeeds without error:
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