Get-Netadapter Will Not Work

Get-Netadapter Will Not Work

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.

1

2 Answers

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.