Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am thinking about using the wired MAC-adr as a unique value in a program. So i need to be sure the MAC-adr is the wired one and NOT the wireless.

$mac = gwmi -computer $compname win32_NetworkAdapterConfiguration | select MACAddress

This is what I started with, but it gives me two addresses. First one is the one I want: 00:00:11:11:22:22 The last one is the wireless address: 00:1F:3C:8E:61:D8

I can't just sort like: select -first 1. Because I don't know what this will get me on other computers.. And btw, this DOES work on ipV6 as well as ipV4?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
130 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try this way:

$mac = gwmi -computer $compname win32_NetworkAdapter | ? { $_.AdapterType -match "802.3" } |  select MACAddress

If there's more than one you need to do a selection.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...