0

I am trying to query for physical network adapters and I see different result from different approaches

get-wmiobject win32_networkadapter  -Filter "NetEnabled='True' and  PhysicalAdapter='True'"| select netconnectionid, name, netconnecionstatus

returns

get-wmiobject win32_networkadapter

whereas

get-netadapter -physical

returns only

enter image description here

I was under the assumption that -physical is same as PhysicalAdapter='True' but that don't seem to be the case as seen from the results. why?

1
  • I think virtual networks are not recognized as physical by one, and not by another. Commented Dec 2, 2016 at 19:34

2 Answers 2

1

The cmdlets return different data types:

[PS]> (Get-NetAdapter -Physical).GetType().FullName
Microsoft.Management.Infrastructure.CimInstance

[PS]> (Get-WmiObject -Class "Win32_NetworkAdapter").GetType().FullName
System.Object[]

[PS]> (Get-WmiObject -Class "Win32_NetworkAdapter")[0].GetType().FullName
System.Management.ManagementObject

I'm not sure I can do the CimInstance-vs-WMI discussion any justice here, so you might want to start with reading these blogs:

The cmdlets might be doing different things under the hood, but this doesn't necessarily explain why you see more interfaces using one method. It might simply be that some of the interfaces returned by Get-WMIObject are "hidden" interfaces. Note that Get-NetAdapter supports the -IncludeHidden switch.

Get-NetAdapter

The Get-NetAdapter cmdlet gets the basic network adapter properties. By default only visible adapters are returned.

Sign up to request clarification or add additional context in comments.

1 Comment

It is not hidden. I think, it is because virtual Ethernet adapters are not exposed thru Powershell but it does thru the win32 api
0

As I don't have Windows 8/2012 installed I can't verify the exact xml used for Get-NetAdapter I can't post it here but what is it probably doing is following a default formatting template for that cmdlet.

It's basically a XML file that decides what properties to display and how to format them.

The WMI object dose not have any as its not a product of a direct cmdlet, its just pulling informations from the wmi class.

3 Comments

The question is not about formatting; it is about the results. 'Intel Centrino Advanced-N 6205' is the only physical adapter, but why does win32_networkadapter show 3 other results which as just logical. Sorry for not being clear. I have updated the question.
So Get-NetAdapter -Physical is only displaying the physical adapters. Maybe -Physical acts as a filter? It sounds like your asking why the wmi class gives you all adapter whereas the cmdlet gives you the filtered results? Or not? :)
yes. -physical is a filter and so is PhysicalAdapter='True'. The question is why aren't they returning the same value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.