问题
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?
回答1:
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.
回答2:
Try to be more specific, for example:
(gwmi win32_NetworkAdapter -computer $compname -filter "NetConnectionID='Local Area Connection'").MACAddress
来源:https://stackoverflow.com/questions/10583535/get-wired-mac-address-from-computer-server