Hi guys,
I am very new to Powershell.
Dont suppose you could shed some light why the command Get-NetAdapter -name * returned nothing…? yes… nothing… like this:
PS C:\Users\xxx> Get-NetAdapter -name *
PS C:\Users\xxx>
Googled this someone said Network Setup Service and WMI service are needed to be running, and yes they are
Using Powershell 7 with administrator in a Windows 10 Enterprise and did restart the Windows or both services but didnt help
Thanks in advanced
Bill.
tonyd
October 3, 2024, 4:25pm
2
What does this return:
Get-CimInstance -ClassName 'Win32_NetworkAdapter'
PS C:\Windows\System32> Get-CimInstance -ClassName ‘Win32_NetworkAdapter’
DeviceID Name AdapterType ServiceName
0 Microsoft Kernel Debug Network Adapter kdnic
1 WAN Miniport (IKEv2) RasAgileVpn
2 WAN Miniport (L2TP) Rasl2tp
3 OpenVPN Data Channel Offload ovpn-dco
4 WAN Miniport (PPTP) PptpMiniport
5 WAN Miniport (PPPOE) RasPppoe
6 WAN Miniport (IP) Ethernet 802.3 NdisWan
7 WAN Miniport (IPv6) Ethernet 802.3 NdisWan
8 WAN Miniport (Network Monitor) Ethernet 802.3 NdisWan
9 Bluetooth Device (Personal Area Network) Ethernet 802.3 BthPan
10 Intel(R) Dual Band Wireless-AC 3168 Ethernet 802.3 Netwtw04
11 WAN Miniport (SSTP) RasSstp
12 Apple Mobile Device Ethernet
13 Microsoft Wi-Fi Direct Virtual Adapter #3 Ethernet 802.3 vwifimp
14 Intel(R) Ethernet Connection (12) I219-V Ethernet 802.3 e1dexpress
15 TAP-NordVPN Windows Adapter V9 Ethernet 802.3 tapnordvpn
16 Apple Mobile Device Ethernet
17 Microsoft Wi-Fi Direct Virtual Adapter #4 Ethernet 802.3 vwifimp
19 TAP-Windows Adapter V9 Ethernet 802.3 tap0901
20 VMware Virtual Ethernet Adapter for VMnet1 Ethernet 802.3 VMnetAdapter
21 VMware Virtual Ethernet Adapter for VMnet8 Ethernet 802.3 VMnetAdapter
PS C:\Windows\System32>
tonyd
October 3, 2024, 4:43pm
4
That seems to imply WMI is all good. Check the value of:
$ErrorActionPreference
If that is set to ‘SilentlyContinue’, change it to ‘Contiue’. Then try your command again. If you get an error, check to make sure the “Network Setup Service” is set to “Manual” start.
The Name parameter does not accept wildcards so just call
Get-NetAdapter
To return all adapters
1 Like
tonyd
October 3, 2024, 5:02pm
6
Interesting … it works fine for me … FYI Worked in both PS 5.1 and 7.4
Hmm yeah works for me too but the Get-Help says false, help bug maybe
tonyd
October 3, 2024, 5:32pm
8
And what you state is also validated here:
-Name
Specifies an array of network adapter names.
Type: String[]
Aliases: ifAlias, InterfaceAlias
Position: 0
Default value: None
Required: False
Accept pipeline input: False
Accept wildcard characters: False
hm…
PS C:\Windows\System32> Get-NetAdapter
PS C:\Windows\System32> $ErrorActionPreference
Continue
PS C:\Windows\System32> Get-NetAdapter -name *
PS C:\Windows\System32>
still nothing…
I’m with neemobeer, I use this command a lot and I never use -Name *
Sadly even the online help shows that as a terrible example but if you scroll down in the online help and look at the -Name parameter “Required = False”
You can also try “Get-NetAdapter -IncludeHidden”
So try the IncludeHidden switch and let us know what you find out.
below is the output from another windows using get-netadapter -name * , i believe it should work…
==================================================================
PS C:\Users\xxx> Get-NetAdapter -name *
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
Ethernet Check Point Virtual Network Adapter … 17 Up 54-04-32-78-37-08 1.1 Gbps
Ethernet 3 Intel(R) Ethernet Connection (23) I2… 16 Disconnected 74-5D-22-9A-8C-2F 0 bps
Bluetooth Network Con…2 Bluetooth Device (Personal Area Ne…#2 11 Disconnected 74-13-EA-A4-79-E5 3 Mbps
Wi-Fi 2 Intel(R) Wi-Fi 6E AX211 160MHz #2 5 Up 74-13-EA-A4-79-E1 866.7 Mbps
PS C:\Users\xxx>
When I try your command Get-NetAdapter -IncludeHidden in the original windows, is still showed nothing… very annoying…
PS C:\Windows\System32> Get-NetAdapter -IncludeHidden
PS C:\Windows\System32>
These commands should return the same adapters as Get-NetAdapter
. What output do you get when running these?
PS Scripts:\> Get-ComputerInfo | Select-Object -ExpandProperty CsNetworkAdapters
PS Scripts:\> Get-CimInstance CIM_NetworkAdapter | Where-Object { $null -ne $_.NetConnectionStatus }
yes these two command worked
PS C:\Users\xxx> Get-ComputerInfo | Select-Object -ExpandProperty CsNetworkAdapters
Description : OpenVPN Data Channel Offload
ConnectionID : OpenVPN Data Channel Offload for NordVPN
DHCPEnabled :
DHCPServer :
ConnectionStatus : MediaDisconnected
IPAddresses :
Description : Bluetooth Device (Personal Area Network)
ConnectionID : Bluetooth Network Connection
DHCPEnabled :
DHCPServer :
ConnectionStatus : MediaDisconnected
IPAddresses :
Description : Intel(R) Dual Band Wireless-AC 3168
ConnectionID : Wi-Fi
DHCPEnabled : False
DHCPServer :
ConnectionStatus : Connected
IPAddresses : {x.x.x.x}
Description : Intel(R) Ethernet Connection (12) I219-V
ConnectionID : Ethernet
DHCPEnabled :
DHCPServer :
ConnectionStatus : MediaDisconnected
IPAddresses :
Description : TAP-NordVPN Windows Adapter V9
ConnectionID : Local Area Connection
DHCPEnabled :
DHCPServer :
ConnectionStatus : MediaDisconnected
IPAddresses :
Description : TAP-Windows Adapter V9
ConnectionID : OpenVPN TAP-Windows6
DHCPEnabled : True
DHCPServer : x.x.x.x
ConnectionStatus : Connected
IPAddresses : {x.x.x.x, fe80::6d25:d041:f88:xxxx}
Description : VMware Virtual Ethernet Adapter for VMnet1
ConnectionID : VMware Network Adapter VMnet1
DHCPEnabled : True
DHCPServer : x.x.x.x
ConnectionStatus : Connected
IPAddresses : {x.x.x.x, fe80::3ea4:42cd:ef9b:xxxx}
Description : VMware Virtual Ethernet Adapter for VMnet8
ConnectionID : VMware Network Adapter VMnet8
DHCPEnabled : True
DHCPServer : x.x.x.x
ConnectionStatus : Connected
IPAddresses : {x.x.x.x, fe80::d3cb:8488:ba09:xxxx}
PS C:\Users\xxx> Get-CimInstance CIM_NetworkAdapter | Where-Object { $null -ne $_.NetConnectionStatus }
DeviceID Name AdapterType ServiceName
3 OpenVPN Data Channel Offload ovpn-dco
9 Bluetooth Device (Personal Area Network) Ethernet 802.3 BthPan
10 Intel(R) Dual Band Wireless-AC 3168 Ethernet 802.3 Netwtw04
14 Intel(R) Ethernet Connection (12) I219-V Ethernet 802.3 e1dexpress
15 TAP-NordVPN Windows Adapter V9 Ethernet 802.3 tapnordvpn
19 TAP-Windows Adapter V9 Ethernet 802.3 tap0901
20 VMware Virtual Ethernet Adapter for VMnet1 Ethernet 802.3 VMnetAdapter
21 VMware Virtual Ethernet Adapter for VMnet8 Ethernet 802.3 VMnetAdapter
PS C:\Users\xxx>
Does it work in Windows PowerShell 5.1 on that machine?
What version of PowerShell 7 is installed? Please post the output of $PSVersionTable
.
When posting your output, please can you use the </> button. If you can’t see it in the toolbar, it will be under the gear icon. This will help greatly with readability.
The command Get-NetAdapater doesnt work in PS 5.1 on that machine
I have both v5.1 and v7.4.5 installed, Get-NetAdapter command doesnt work on both version PS
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.4894
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.4894
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Windows\system32> Get-NetAdapter
PS C:\Windows\system32> Get-NetAdapter -name *
PS C:\Windows\system32>
PS C:\Windows\System32> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS C:\Windows\System32> Get-NetAdapter
PS C:\Windows\system32> Get-NetAdapter -name *
PS C:\Windows\System32>
by the way both of your commands worked on both version PS
What’s the output of:
Get-Module NetAdapter -ListAvailable | Format-List
Might be worth copying the NetAdapter module:
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\NetAdapter
from a working a machine and seeing if that resolves the problem.
Output:
PS C:\Windows\System32> Get-Module NetAdapter -ListAvailable | Format-List
Name : NetAdapter
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\NetAdapter\NetAdapter.psd1
Description :
ModuleType : Manifest
Version : 2.0.0.0
PreRelease :
NestedModules : {MSFT_NetAdapter.cmdletDefinition, MSFT_NetAdapterAdvancedProperty.cmdletDefinition,
MSFT_NetAdapterBinding.cmdletDefinition, MSFT_NetAdapterChecksumOffload…}
ExportedFunctions : {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload,
Disable-NetAdapterEncapsulatedPacketTaskOffload…}
ExportedCmdlets :
ExportedVariables :
ExportedAliases :
PS C:\Windows\System32>
Tried replacing the folder with a working machine but still the same… frustrating…
thanks by the way really appreciated
Any chance that the function has been overridden locally? What’s the output of
Get-Command Get-NetAdapter
Is this a physical machine or a virtual machine? I notice you have a couple of VMware adapters.
Running out of ideas now.
1 Like
PS C:\Users\xxx> Get-Command Get-NetAdapter
CommandType Name Version Source
----------- ---- ------- ------
Function Get-NetAdapter 2.0.0.0 NetAdapter
PS C:\Users\xxx>
Its a physical machine with VMware Workstation installed
One more interesting finding is… a similar command Disable-NetAdapter doesnt work neither
PS C:\Users\xxx> Disable-NetAdapter -name Ethernet
Disable-NetAdapter: No MSFT_NetAdapter objects found with property 'Name' equal to 'Ethernet'. Verify the value of the property and retry.
PS C:\Users\xxx>
tonyd
October 9, 2024, 3:26pm
21
By default only visible adapters are returned
What happens if you enter:
Get-NetAdapter -IncludeHidden
If this shows objects, one would then wonder how/why they are hidden.