1

When using DISM.exe to get Windows optional features using command dism /Online /Get-Features, the program exits within 1 second and outputs the right results. But when using the command Get-WindowsOptionalFeature -Online in powershell, it stucks for minutes and finally returns nothing or returns an error saying Get-WindowsOptionalFeature: Class not registered

Windows version: Windows 11 22H2 Professional (22624.1616)
Powershell version: 7.3.4
DISM version: 10.0.22621.1

I searched on Bing for information, but it seems that nobody is encountering the same issue. I thought about maybe the server is far away, so I used a proxy but nothing changed.


Added

I've found a relative issue on GitHub: PowerShell/PowerShell#13866

CarlGao4
  • 11
  • 3
  • That [issue](https://github.com/PowerShell/PowerShell/issues/13866) is still open. – Luuk Apr 22 '23 at 14:36
  • This issue is being tracked at [PowerShell/PowerShell#13866](https://github.com/PowerShell/PowerShell/issues/13866). – CarlGao4 Apr 23 '23 at 08:23

1 Answers1

0

This is usually caused by a corrupted or damaged WMI registry. You can try rebuilding the WMI, but this should be done with caution!

Try these steps:

  1. Open elevated command prompt
  2. Stop WMI by running net stop winmgmt
  3. Rename WMI repo by typing ren C:\Windows\System32\wbem\Repository Repository.old
  4. Restart WMI by running net start winmgmt
  5. Reboot computer

Try using your PowerShell command again post reboot.

danijeljw-RPC
  • 345
  • 2
  • 13