Get-NetAdapter will not work

0

The first simple example using Get-NetAdapter in Get-Help from Microsoft will not work on my machine. Any suggestions?

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

PS C:\Users\lit> $PSVersionTable

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

It appears that I have the NetAdapter module on my system.

PS C:\Users\pwatson> Get-Module -ListAvailable | Where-Object {$_.Name -Like '*NetAdapter*'}

    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0.0.0    NetAdapter                          {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, Disable-NetAdapt...

I finally got to see all of the ExportedCommands, but Get-NetAdapter is not among them.

Get-Module -ListAvailable | Where-Object {$_.Name -Like '*NetAdapter*'} | Select-Object -Property {$_.ExportedCommands} | Format-Custom

Based on Seth's answer, I have:

C:\Users\pwatson>winmgmt /verifyrepository
WMI repository verification failed
Error code:     0x80041003
Facility:       WMI
Description:    Access denied

I am going to accept Seth's answer and post a new question about permission settings.

windows-10
powershell
windows-networking
asked on Super User Apr 20, 2017 by lit • edited Apr 21, 2017 by lit

2 Answers

1

Network Setup Service must be Running for "Get-NetAdapter" command to return anything in PowerShell.

answered on Super User Apr 15, 2021 by MariusM
0

Get-NetAdpater would not be a module but rather a command. You would need to run Get-Command instead of Get-Module. Furthermore if you carefully read the exception in the first case, it's Metadata exception. It's telling you it can't read the backend data structure. 0x80041010 seems to be the code for invalid class returned by WMI. So either your WMI might be damaged (this might help) or it might be that you have insufficient permissions. The latter is way more unlikely than the first.

From the above link in order to rebuild you could try:

1. winmgmt /verifyrepository
If the result is shown as inconsistent, go to step 2
2. winmgmt /salvagerepository
3. winmgmt /verifyrepository - to check again wmi repository had been repaired successfully

I'm leaving the more advanced solution out. As this should help you to verify whenever your WMI might be damaged.

answered on Super User Apr 21, 2017 by Seth

User contributions licensed under CC BY-SA 3.0