Skip to content

DISM cmdlets not working in Powershell 7 #15428

Closed as duplicate
Closed as duplicate

Description

Steps to reproduce

Type

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

Expected behavior

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\Administrator> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'


Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Actual behavior

PowerShell 7.2.0-preview.5
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS C:\openssh> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Get-WindowsCapability: Class not registered

Environment data

Powershell 5.1 (working)

PS C:\Users\Administrator> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.21376.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.21376.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Powershell 7 (installed from Store)

PS C:\openssh> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.5
PSEdition                      Core
GitCommitId                    7.2.0-preview.5
OS                             Microsoft Windows 10.0.21376
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional Notes

Referenced in PowerShell/WindowsCompatibility#87
I wasn't sure if it was the right place to report this issue, so I'm reporting here.

Activity

  1. added
    Needs-Triage
    on May 20, 2021
  2. TravisEz13 commented on May 27, 2021

    @TravisEz13
    Member

    I am not able to reproduce this issue
    image
    It looks like you are running an insider build of Windows. The problem may be there.

  3. added
    Issue-Bug
    Resolution-External
    on May 27, 2021
  4. removed
    Needs-Triage
    on May 28, 2021
  5. blacklightpy commented on May 28, 2021

    @blacklightpy
    Author

    Yes, I was on build 21376, and I'm not on 21390 and it is still there.

    Also, apparently it seems to recognize the command when I'm running without elevation.

    PS C:\Users\Blacklight> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
    Get-WindowsCapability: The requested operation requires elevation.
    

    But this is different to the output on Powershell 5.1

    PS C:\Users\Blacklight> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
    Get-WindowsCapability : The requested operation requires elevation.
    At line:1 char:1
    + Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-WindowsCapability], COMException
        + FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsCapabilityCommand
    

    It's like Powershell 7 recognizes the cmdlet itself that it requires elevation, but doesn't know it's function.
    I thought that was worth adding.

  6. ghost closed this as completedon May 29, 2021
  7. dr-kristau commented on Oct 20, 2021

    @dr-kristau

    It's like Powershell 7 recognizes the cmdlet itself that it requires elevation, but doesn't know it's function.
    I thought that was worth adding.

    I can reproduce exactly the same issue using the following version:

    Screenshot from 2021-10-20 13-55-56

    When I run without Administrator privileges I obtain this:

    Screenshot from 2021-10-20 13-58-23

    And with Administrator privileges I obtain this:

    Screenshot from 2021-10-20 14-01-05

    Worth mentioning that if I use Windows PowerShell:

    Screenshot from 2021-10-20 14-08-47

    I can run the command successfully, although only with Administrator privileges:

    Screenshot from 2021-10-20 14-09-10

  8. davetapley commented on Nov 23, 2021

    @davetapley

    Travis Plunk (@TravisEz13) I was able to repro this in a Windows 10 Pro VM on Azure (after installing Powershell 7):

    (I was following this guide).

    Screen Shot 2021-11-23 at 1 16 00 PM

    Screen Shot 2021-11-23 at 1 19 12 PM

  9. iSazonov commented on Nov 24, 2021

    @iSazonov
    Collaborator

    This works well for me. Can you check on fresh Windows 10?

  10. blacklightpy commented on Nov 24, 2021

    @blacklightpy
    Author

    This works well for me. Can you check on fresh Windows 10?

    I can't right now because I have a lot of apps required for work

  11. francogp commented on Feb 8, 2022

    @francogp

    If I run the command on OLD powershell, it works
    image

    But If I use the new powershell, it fails
    image

  12. jgwinner commented on Feb 23, 2022

    @jgwinner

    I can duplicate this issue on Windows 11 and just updated last night. It's quite irritating as I can't get VS Code SSH setup for a critical work issue. I was able to get SSH loaded by going through the control panel though.

    It takes QUITE a long time as well. More details:

    > $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      7.2.1
    PSEdition                      Core
    GitCommitId                    7.2.1
    OS                             Microsoft Windows 10.0.22557
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    

    $PSVersionTable.Values
    Core
    Microsoft Windows 10.0.22557
    
    Major  Minor  Build  Revision
    -----  -----  -----  --------
    1      1      0      1
    1      0      -1     -1
    2      0      -1     -1
    3      0      -1     -1
    4      0      -1     -1
    5      0      -1     -1
    5      1      10032  0
    6      0      0      -1
    6      1      0      -1
    6      2      0      -1
    7      0      0      -1
    7      1      0      -1
    7      2      1      -1
    
    Major           : 7
    Minor           : 2
    Patch           : 1
    PreReleaseLabel :
    BuildLabel      :
    
    Win32NT
    2      3      -1     -1
    7.2.1
    3      0      -1     -1
    
  13. 14 remaining items

  14. WebTiger89 commented on Dec 8, 2022

    @WebTiger89

    "Fucking shit Microsoft" others might be saying, but not me. I like Microsoft and its support.

  15. RobotToaster commented on Dec 12, 2022

    @RobotToaster

    So the official advice from microsoft, is to not trust the microsoft store to install things correctly?

  16. doctordns commented on Dec 12, 2022

    @doctordns
    Collaborator

    I suspect the best advice is that you have many ways to install PowerShell 7. Some come with limitations based on the underlying delivery mechanisms. You need to choose what is best for your organisation.

    Personally, I use the iInstall-PowerShell.ps1 script in this repo which gives me all the control I need over installation.
    Winget and Chocolatey are also methods you can use. Chocolatey even has cmdlets to simplify your journey. For simple use cases, you can also use a more locked-down version of PowerShell delivered via the Store. And if you are really hard-core, you can come here and get the release components directly from the source.

  17. rizolo commented on Dec 12, 2022

    @rizolo

    I can confirm that using winget install Microsoft.PowerShell, after uninstalling the MS Store copy, that this does in fact let me use Get-WindowsOptionalFeature -Online

  18. WebTiger89 commented on Dec 12, 2022

    @WebTiger89

    Riz Virani (@rizolo) That's because winget installs the .msi Version of Powershell. But this issue is about the appx (UWP) version of powershell which can be obtained via Microsoft Store. While the powershell appx version 5.1 works, Powershell 7.2.6 and 7.3.0-preview.8 don't. I didn't test the final powershell 7.3.0 version.

  19. WebTiger89 commented on Dec 12, 2022

    @WebTiger89

    Thomas Lee (@doctordns)
    There is enough evidence here that the UWP version does not work as expected (at least the newer versions).

    It is fine if this topic is too complicated for you and you don't understand what is going on, but understand that this is a real issue that should be tackled so reopen this issue or remove powershell from store and or do not provide an UWP version.

  20. FuccDucc commented on Dec 13, 2022

    @FuccDucc

    And you know, it doesn't matter if "it works on my machine" kind of crap. It's a MICROSOFT issue. If you're going to close a real issue, you should at least open another issue with the correct group.

    This kind of "closed because it's not a problem" is utterly rife with the new Microsoft. What happened? You guys used to be a great company.

    It's bureaucracy and that the teams within many large companies don't really work together/communicate properly or at all..
    Even after more than a year, Microsoft didn't accomplish to let the OS/Appx/whatever other team, make a Microsoft product (that advertises itself as an improvement over the standard version) integrate properly. It's a failure of the chain or maybe the MS devs in github here are low level ones that don't have enough connections within the "real" company and can't break some barriers of team interoperability and cooperation. Of course, in the end, the result being produced is a symptom of lack of quality as a company, but the maintainers of this repo don't care enough and it's convenient to shove any such things with the thought "Not our problem / we dont get paid for this / there is invisible walls within Microsoft we cant break up, neither are we interested in looking at a solution for that"

    I'm probably mixing observations with the other very similar issue #13138 where exactly the same root causes lead the maintainers to say "We dont care, not our problem, ok, closed"

  21. daxian-dbw commented on Feb 7, 2023

    @daxian-dbw
    Member

    Just FYI, the "Class not registered" error happens in PowerShell installed from MS Store is likely due to the registry virtualization applied to Store apps, see #13866 (comment). The issue is tracked by #13866, and this is the latest updates on that issue: #13866 (comment)

  22. Warrentheo commented on Mar 25, 2023

    @Warrentheo

    I can confirm that deleting the msstore version corrected this issue for me.

  23. JunielKatarn commented on Oct 24, 2024

    @JunielKatarn

    Running this command from Windows Powershell (Admin) (not PWSH) worked, but it failed on the first attempt:

    Add-WindowsCapability -Online -Name $someRsatFeature
  24. thegitworker commented on Jun 25, 2026

    @thegitworker

    Confirm 5 years later still an issue. I cannot run the Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' command in PowerShell 7.6.3. downloaded from the Microsoft Store. After uninstalling and installing PowerShell 7.6.3 from the MSI it works.

    No idea why this is closed when the issue still exists.

  25. added
    Package-MSIX
    on Jun 26, 2026
  26. kilasuit commented on Jun 26, 2026

    @kilasuit
    Collaborator

    Closing as duplicate of #13866 as whilst the cmdlets mentioned are different the underlying issue is the same

  27. Psychlist1972 commented on Oct 29, 2026

    @Psychlist1972

    I ran into this yesterday on a Windows 11 26h2 box, with PowerShell 7.x installed via MSI, not via MSIX. #13866 seems different as it's about MSIX-installed version.

    Image

    I was trying to install the OpenSSH Server capability for Github Copilot remote agents. The call took quite some time to run, and then failed with "Class not registered" as I recall. This was in an admin terminal.

    I then shelled to Windows PowerShell in the same terminal, and although it took a crazy amount of time to install (like 30 minutes), it completed.

    So I just repeated the test to have better info. Under PowerShell 7.6.9, the Get-WindowsCapability call takes over two minutes to return the error under 7.x and returns almost instantly under 5.x

    Image

    Edit: Actually, somehow, I'm seeing the MSIX version instead of the version I thought I had installed.

    Image

    But if MSIX truly is the problem, 7.7.0 ONLY offers MSIX from this point forward, which will continue to break these commands.

    Pete
    Microsoft

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

    Issue-BugOS-WindowsPackage-MSIXResolution-External

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions