Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DISM cmdlets not working in Powershell 7 #15428

Closed
blacklightpy opened this issue May 20, 2021 · 32 comments
Closed

DISM cmdlets not working in Powershell 7 #15428

blacklightpy opened this issue May 20, 2021 · 32 comments
Labels
Issue-Bug Issue has been identified as a bug in the product OS-Windows Resolution-External The issue is caused by external component(s).

Comments

@blacklightpy
Copy link

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.

@blacklightpy blacklightpy added the Needs-Triage The issue is new and needs to be triaged by a work group. label May 20, 2021
@TravisEz13
Copy link
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.

@TravisEz13 TravisEz13 added Issue-Bug Issue has been identified as a bug in the product Resolution-External The issue is caused by external component(s). labels May 27, 2021
@iSazonov iSazonov removed the Needs-Triage The issue is new and needs to be triaged by a work group. label May 28, 2021
@blacklightpy
Copy link
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.

@ghost
Copy link

ghost commented May 29, 2021

This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

@ghost ghost closed this as completed May 29, 2021
@dr-kristau
Copy link

dr-kristau commented Oct 20, 2021

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

@davetapley
Copy link

@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

@iSazonov
Copy link
Collaborator

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

@blacklightpy
Copy link
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

@francogp
Copy link

francogp commented Feb 8, 2022

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

But If I use the new powershell, it fails
image

@jgwinner
Copy link

jgwinner commented Feb 23, 2022

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

@doctordns
Copy link
Contributor

Running latest Insiders Win 11 build (22557) and it works as expected:

PS C:\Foo> $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, 5.0, 5.1.10032.0, 6.0.0, 6.1.0, 6.2.0, 7.0.0, 7.1.0, 7.2.1}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

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

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

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

@jgwinner
Copy link

Why is this closed? It's still a bug.

@jgwinner
Copy link

@doctordns Interesting, as near as I can tell our versions were identical. I don't use PS that much (I use JPSoft's TCC), so maybe there's something you've installed that I didn't - that Get-WindowsCapability doesn't check for but relies on.

@ghost
Copy link

ghost commented Jul 20, 2022

I am able to reproduce with PowerShell installed using the msixbundle, but not installed using the MSI (the service error can safely be ignored as a result of running in Windows Sandbox).
image
image

@doctordns
Copy link
Contributor

The DISM module is a Windows PowerShell module, NOT a PowerShell 7 module.

I see this:

PS C:\Foo> Get-WindowsCapability -Online | ft

Name                                                                State
----                                                                -----
Accessibility.Braille~~~~0.0.1.0                               NotPresent
Analog.Holographic.Desktop~~~~0.0.1.0                          NotPresent
App.StepsRecorder~~~~0.0.1.0                                    Installed
App.WirelessDisplay.Connect~~~~0.0.1.0                         NotPresent
Browser.InternetExplorer~~~~0.0.11.0                            Installed
DirectX.Configuration.Database~~~~0.0.1.0                      NotPresent

@jgwinner
Copy link

I see this, running in an elevated prompt:

PowerShell 7.2.5
Copyright (c) Microsoft Corporation.

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

PS C:\Windows\System32> Get-WindowsCapability -Online | ft
Get-WindowsCapability: Class not registered

PS C:\Windows\System32>

@jgwinner
Copy link

It's really simple. You should be able to install PowerShell 7, on a new machine, and it should work. If it doesn't, either it's not installing enough 'stuff' or the error message needs to indicate what does need to be installed. Empty stubs do no one any good.

My bets on a bad install program.

PS C:\Windows\System32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Microsoft Windows 10.0.25158
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\Windows\System32>

@doctordns
Copy link
Contributor

That sounds like a borked Windows. Class not registered means that something is missing from your windows installation. The DISM cmdlets are shipped with Windows and the installation should properly register any classes needed.

One suggestion is an upgrade-install. Use the ISO of your current windows version and use it "upgrade" your existing installation. this should re-register the class. Or just do a fresh install and move on.

@jgwinner
Copy link

My windows is not borked. It was a fresh install.

It works fine for everything else.

YOUR windows looks like it's been upgraded over the years - you probably installed something a long time ago, that a fresh install doesn't install.

I installed OpenSSH another way, and everything is fine - and most other PowerShell things work fine.

Have YOU tried a fresh install on a new box?

@WebTiger89
Copy link

WebTiger89 commented Oct 1, 2022

Shit still happens with Powershell 7.2.6 installed as Appx package, same for 7.3.0-preview.8

image

Powershell 5.1 works:
image

What also works is the msi Version of Powershell 7:
image

@ModelsRUs
Copy link

ModelsRUs commented Nov 12, 2022

I don't know why this issue is closed. I'm experiencing the same thing.
Windows 11 Pro.
Running PowerShell 7.3.0. Results identical in multiple shells: PowerShell, Terminal, or VS Code.
Statement: Get-WindowsDriver -online -all

with Admn rights, returns "Class not registered".
without Admin rights:, returns "The requested operation requires elevation"

running the same under PowerShell ISE ( 5.1.22000.832 ) as Administrator, I get output as expected.

Update:
After another (more careful) read of this thread, I uninstalled PowerShell. Then, instead of re-installing from the Windows Store, I downloaded / installed the [PowerShell-7.3.0-win-x64.msi] package directly from https://github.com/PowerShell/PowerShell/releases/tag/v7.3.0. The issue now seems to be resolved.

@doctordns
Copy link
Contributor

The reason the issue is closed (here) is that this is not a PowerShell issue. The module is/was a Windows PowerShell module. It appears in later versis of Windows, the module works fine (assumein elevation). This is not an issue we can fix.

@rez9x
Copy link

rez9x commented Dec 7, 2022

As this was the first result in a web search of this issue, I want to add how I resolved my issue. On a fresh install of Windows 11, I installed PowerShell 7 from the Microsoft Store. After reading Nytrona's comment, I removed the PowerShell install from the Microsoft Store and downloaded the MSI from Github. Both are 7.3.0, but the issue was resolved by installing the MSI instead.

In my case, this was a Microsoft Store issue and not a PowerShell issue.

@jgwinner
Copy link

jgwinner commented Dec 7, 2022

The reason the issue is closed (here) is that this is not a PowerShell issue.

It certainly is - rez9x showed it's a PowerShell in the Microsoft Store issue. That's still a Microsoft issue.

Having an incorrect install I would think is still a PowerShell install. How does anyone else in the company know what to install if you guys don't give them the right install? Seems weird.

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.

Now, people complain endlessly about stupid crap that should be a trival fix and the attitude is "closed due to Triage" (that's not what Triage is!) or "not our problem".

It's all your problem. Fix your stuff. Somehow.

@WebTiger89
Copy link

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

@Loki44
Copy link

Loki44 commented Dec 12, 2022

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

@doctordns
Copy link
Contributor

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.

@rizolo
Copy link

rizolo commented Dec 12, 2022

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

@WebTiger89
Copy link

@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.

@WebTiger89
Copy link

WebTiger89 commented Dec 12, 2022

@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.

@FuccDucc
Copy link

FuccDucc commented Dec 13, 2022

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"

@daxian-dbw
Copy link
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)

@Warrentheo
Copy link

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product OS-Windows Resolution-External The issue is caused by external component(s).
Projects
None yet
Development

No branches or pull requests