DISM.exe works but Get-WindowsOptionalFeature (powershell) fails

366 Views Asked by At

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

1

There are 1 best solutions below

1
danijeljw-RPC On

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.