Get-Net* PowerShell cmdlets failing with Invalid class

4

How can I troubleshoot and fix Get-Net* PowerShell cmdlets? All of the following are failing with Invalid class. I'm using Windows 10, version 1511 and do not have the option to upgrade to 1607 at this point.

First PowerShell version:

PS C:\WINDOWS\system32> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      0      10586  672

Errors:

PS C:\WINDOWS\system32> Get-NetAdapter
Get-NetAdapter : Invalid class
At line:1 char:1
+ Get-NetAdapter
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetAdapter:ROOT/StandardCimv2/MSFT_NetAdapter) [Get-NetAdapter], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapter

PS C:\WINDOWS\system32> Get-NetIPAddress
Get-NetIPAddress : Invalid class
At line:1 char:1
+ Get-NetIPAddress
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetIPAddress:ROOT/StandardCimv2/MSFT_NetIPAddress) [Get-NetIPAddress], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetIPAddress

PS C:\WINDOWS\system32> Get-NetAdapterHardwareInfo
Get-NetAdapterHardwareInfo : Invalid class
At line:1 char:1
+ Get-NetAdapterHardwareInfo
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetAdapterHardwareInfoSettingData:ROOT/StandardCi...InfoSettingData
   ) [Get-NetAdapterHardwareInfo], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapterHardwareInfo

PS C:\WINDOWS\system32> Get-NetAdapterBinding
Get-NetAdapterBinding : Invalid class
At line:1 char:1
+ Get-NetAdapterBinding
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetAdapterBindingSettingData:ROOT/StandardCi...dingSettingData) [Ge
   t-NetAdapterBinding], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapterBinding

PS C:\WINDOWS\system32> Get-NetAdapterStatistics -Name "Wi-Fi"
Get-NetAdapterStatistics : Invalid class
At line:1 char:1
+ Get-NetAdapterStatistics -Name "Wi-Fi"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetAdapterStatisticsSettingData:ROOT/StandardCi...ticsSettingData)
   [Get-NetAdapterStatistics], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapterStatistics

PS C:\WINDOWS\system32> Get-NetAdapterStatistics -Name "Ethernet"
Get-NetAdapterStatistics : Invalid class
At line:1 char:1
+ Get-NetAdapterStatistics -Name "Ethernet"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (MSFT_NetAdapterStatisticsSettingData:ROOT/StandardCi...ticsSettingData)
   [Get-NetAdapterStatistics], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapterStatistics

I'm trying to use Docker for Windows 10 (which used to work) but the PowerShell failures are causing Docker to not start (GitHub issue). The errors are occurring on my host, not inside Docker containers. For the sake of this question you should ignore the Docker details, it is just that I cannot use Docker due to this problem.

windows-10
powershell
asked on Super User Dec 2, 2016 by bbodenmiller • edited Dec 2, 2016 by bbodenmiller

1 Answer

8

Thanks to a thread on the Microsoft TechNet Forum, we can see that the WMI repository is corrupted and can be fixed as follows:

  1. Disable and stop the WMI service
sc config winmgmt start= disabled
net stop winmgmt
  1. Run the following commands
 Winmgmt /salvagerepository %windir%\System32\wbem
 Winmgmt /resetrepository %windir%\System32\wbem
  1. Re-enable the WMI service and reboot
 sc config winmgmt start= auto

If the problem remains, then try the following steps to rebuild the repository:

  1. Disable and stop the WMI service
 sc config winmgmt start= disabled     (note that there is a blank between '=' and 'disabled')
 net stop winmgmt
  1. Rename the repository folder (located at %windir%\System32\wbem\repository) to repository.old

  2. Re-enable the WMI service

sc config winmgmt start= auto

  1. Reboot the machine.

If the above doesn't work try chkdsk, sfc, and dism. Additionally you can try a Windows Repair Install.

answered on Super User Dec 3, 2016 by bbodenmiller • edited Dec 3, 2016 by bbodenmiller

User contributions licensed under CC BY-SA 3.0