Skip to content

Get-WindowsOptionalFeature -Online fails on PowerShell from MSIX installation - [Get-WindowsOptionalFeature: Class not registered] #13866

Description

Steps to reproduce

Get-WindowsOptionalFeature -Online

>Get-WindowsOptionalFeature: Class not registered

get-error

Exception             :
    Type       : System.Runtime.InteropServices.COMException
    ErrorCode  : -2147221164
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
    Message    : Class not registered

    Source     : System.Management.Automation
    HResult    : -2147221164
CategoryInfo          : NotSpecified: (:) [Get-WindowsOptionalFeature], COMException
FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand
InvocationInfo        :
    MyCommand        : Get-WindowsOptionalFeature
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Get-WindowsOptionalFeature -Online
    PositionMessage  : At line:1 char:1
                       + Get-WindowsOptionalFeature -Online
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Get-WindowsOptionalFeature
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Expected behavior

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core

Get-WindowsOptionalFeature -Online

FeatureName : Printing-PrintToPDFServices-Features
State       : Enabled

FeatureName : Windows-Defender-Default-Definitions
State       : Disabled

FeatureName : Printing-XPSServices-Features
State       : Enabled

...

Actual behavior

Error: Get-WindowsOptionalFeature: Class not registered

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.0-rc.2
PSEdition                      Core
GitCommitId                    7.1.0-rc.2
OS                             Microsoft Windows 10.0.20211
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Oct 25, 2020
  2. iSazonov commented on Oct 26, 2020

    @iSazonov
    Collaborator
        Type       : System.Runtime.InteropServices.COMException
        ErrorCode  : -2147221164

    /cc Dongbo Wang (@daxian-dbw) Patrick Meinecke (@SeeminglyScience) who could comment the exception.

  3. SeeminglyScience commented on Oct 26, 2020

    @SeeminglyScience
    Contributor

    Ben Wilkinson (@brwilkinson) does it work in Windows PowerShell? I can't repro which makes me lean towards it being an issue with the Windows build you're on.

    Can anyone else on the Windows 10 dev channel repro?

  4. SteveL-MSFT commented on Oct 26, 2020

    @SteveL-MSFT
    Member

    This works on my system with 7.1-rc2 and Windows 20H2 (build 19042). That COMException simply means the cmdlet is trying to use a COM object that isn't found. @brwilinson, is your repro showing that on the same system 7.0.3 works, but 7.1-rc2 does not?

  5. iSazonov commented on Oct 26, 2020

    @iSazonov
    Collaborator

    Microsoft Windows 10.0.20211

    I believe it is better to use Windows Feedback tool to report the issue.

  6. brwilkinson commented on Oct 26, 2020

    @brwilkinson
    Author

    Steve Lee (@SteveL-MSFT) yes correct

    $PSVersionTable
    PSVersion 5.1.20211 <-- works as expected
    PSVersion 7.0.3 <-- works as expected
    PSVersion 7.1.0-rc.2 <-- hangs for quite a while (assuming a COM timeout), then fails with the COMException.

    Get-WindowsOptionalFeature: Class not registered

    Repros on both of my main machines.

    My second machine is running a later version: Microsoft Windows 10.0.20241

  7. rjmholt commented on Oct 27, 2020

    @rjmholt
    Collaborator

    I just tried this on my machine:

    > systeminfo | select -first 2 -skip 2
    OS Name:                   Microsoft Windows 10 Enterprise Insider Preview
    OS Version:                10.0.21246 N/A Build 21246
    
    > Get-WindowsOptionalFeature -Online
    
    FeatureName : Printing-PrintToPDFServices-Features
    State       : Enabled
    
    FeatureName : Windows-Defender-Default-Definitions
    State       : Disabled
    
    FeatureName : Printing-XPSServices-Features
    State       : Enabled
    
    ...
    

    Two things Ben Wilkinson (@brwilkinson):

    • Can you try to reproduce on a newer version of Windows?
    • Can you try with PS 7.1-preview.5?

    Because this is done by Dism, which touches COM directly itself (rather than going through PowerShell), this may be caused by changes in .NET rather than in PowerShell.

  8. brwilkinson commented on Oct 27, 2020

    @brwilkinson
    Author

    I am OOF at the moment, can test it when back on keyboard.

    Rob Holt (@rjmholt) by any chance could you test with the store Preview msix version.

    • That is one other variable that we should check first.
  9. SteveL-MSFT commented on Oct 27, 2020

    @SteveL-MSFT
    Member

    Ok, I can repro this from Store installed one. I suspect it's due to registry virtualization which isn't supposed to be active.

  10. changed the title [-]Get-WindowsOptionalFeature -Online fails on 7.1.0-rc.2 - [Get-WindowsOptionalFeature: Class not registered][/-] [+]Get-WindowsOptionalFeature -Online fails on 7.1.0-rc.2 (MSIX)- [Get-WindowsOptionalFeature: Class not registered][/+] on Oct 27, 2020
  11. added
    Issue-BugIssue has been identified as a bug in the product
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Oct 27, 2020
  12. removed this from the 7.2-Consider milestone on Dec 7, 2020
  13. 50 remaining items

  14. DoCode commented on May 1, 2026

    @DoCode

    Also in PowerShell 7.7.0-preview.1:

    Get-WindowsOptionalFeature
    Add-AppxProvisionedPackage
    
  15. SteveL-MSFT commented on May 8, 2026

    @SteveL-MSFT
    Member

    We're working with Windows team on this as the fix isn't in PS7

  16. brwilkinson commented on May 25, 2026

    @brwilkinson
    Author

    This is the default install method for pwsh now isn't it?

    That's a bit unfortunate.. 😂

    Maybe for the best, given this issue had aged, could be good motivation to get it resolved 🤞

  17. teamiisjonathon commented on May 26, 2026

    @teamiisjonathon

    This is garbage. Winget is suppose to be pulling the same binary that is on the Microsoft Download page. If you uninstall the winget version and install the MSI from the Microsoft page , this issue is resolved. Why is it that Microsoft's "fix" tends to be an uninstall and re-install. The winget Microsoft packages should be verified and tested before being put out in the wild!

  18. linghengqian commented on May 30, 2026

    @linghengqian

    I feel like I've traveled through time. I clearly remember that in 2024 and 2025, I could do this.

    # Open Windows PowerShell
    winget install --id Microsoft.PowerShell --source winget --exact
    # Open PowerShell 7 with administrator privileges
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

    However, starting sometime in 2026, I will receive an error message like "Class not registered",

    PS C:\Users\lingh> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
    Enable-WindowsOptionalFeature: 没有注册类
    PS C:\Users\lingh> Enable-WindowsOptionalFeature -FeatureName "Containers-DisposableClientVM" -All -Online
    Enable-WindowsOptionalFeature: 没有注册类
    PS C:\Users\lingh>

    The only issue I could find was the current one, which turned out to have existed since 2020. This is completely contrary to my memories of 2024 and 2025.

    update in 2026.05.30: I think I know the reason now. 😇See https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows?view=powershell-7.6#install-powershell-using-winget .

    Beginning with the winget package for PowerShell 7.6.0, winget installs the MSIX package by default.

  19. Karl-WE commented on Jul 29, 2026

    @Karl-WE

    We're working with Windows team on this as the fix isn't in PS7

    Steve Lee (@SteveL-MSFT) do I understand correctly that Windows Server / Servicing team is responsible for the fix in DISM module, discussed in this thread?

    If yes,
    will this address it for both Windows Client and Windows Server OS?

  20. kilasuit commented on Jul 30, 2026

    @kilasuit
    Collaborator

    Karl Wester-Ebbinghaus (@Karl-WE) it should however this is all dependent on release cycles. Also I don't think that it is likely to be seen as a security fix which would stop it coming in the usual patch Tuesday cycle.

    I'd expect it to show in one of the Windows Client Insider builds before it lands in any of the general use builds of Windows Client.

    But yes that would be my expectation, however the "when" that's unfortunately the million (currency of your choice) question.

  21. SteveL-MSFT commented on Aug 10, 2026

    @SteveL-MSFT
    Member

    We're working with Windows team on this as the fix isn't in PS7

    Steve Lee (@SteveL-MSFT) do I understand correctly that Windows Server / Servicing team is responsible for the fix in DISM module, discussed in this thread?

    If yes, will this address it for both Windows Client and Windows Server OS?

    Expectation is that this will be address for both Windows Client and Server OS

  22. Karl-WE commented on Aug 11, 2026

    @Karl-WE

    Steve Lee (@SteveL-MSFT) that's great news. Fingers crossed there will be a good solution and backport to WS2022 as long it's in mainstream support, to avoid friction across the fleet.

    There is an issue open which is collecting all the regressions known with MSIX. I have a question,
    There are some details missing and I wonder if we have to raise an issue for every item so it can be tracked better. Or it is okay to comment below the collection. I like that question because, mscx and a dism command is stated, and I expanded in the comments below that there are other commands affected in the same module.

    Generally speaking I know it's not your area but I would appreciate if I could get in touch with the team working on the dism module. I've realized two to three commands that are missing in the module which made it impossible to adopt this module as a successor to the native dism commands, install the adoption rate of the module is low and also in the official documentation and other parts of products it is rather the case that Microsoft is still using native commands instead of the PowerShell. Maybe it's naive but I'm thinking it's a good opportunity if there are on it anyway they could add this three commands that I have in mind I see missing which is causing a blocker to adopt it.
    I hope you are great that I'm commenting on this year it's at least remote related to the dism/ msix.

  23. bogdan-patraucean commented on Sep 4, 2026

    @bogdan-patraucean

    Steve Lee (@SteveL-MSFT) any updates? This seems to be an issue using DISM API in any packaged MSIX app, not just powershell.

  24. mamoreau-devolutions commented on Sep 23, 2026

    @mamoreau-devolutions

    I'm setting up a new laptop and hitting this problem. PowerShell 7.7 is just around the corner and drops the MSI installer. This needs to be prioritized

  25. HotCakeX commented on Sep 24, 2026

    @HotCakeX

    Just a reminder that this is not a problem in PowerShell or Windows. You just have to use the DISM APIs correctly in packaged apps. I shared how to do it above, and in this article: https://github.com/HotCakeX/Harden-Windows-Security/wiki/DISM-API-in-Packaged-Apps-and-the-Mechanics-of-Child-Process-Identity

    Windows offers built-in and documented APIs to use it. At most, the change will need to happen in the DISM component itself, not Windows and not PowerShell.

    There is no reason to wait for any fix when you can use DISM in packaged apps right now.

    GitHub
    Harden Windows Safely, Securely using Official Supported Microsoft methods and proper explanation | Always up-to-date and works with the latest build of Windows | Provides tools and Guides for Pers...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Blockedblocked on something external to this repoIssue-BugIssue has been identified as a bug in the productKeepOpenThe bot will ignore these and not auto-closeOS-WindowsPackage-MSIXIssue occurs with MSIX packageWG-Maintainers-Buildspecific to affecting the buildWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions