Get wired MAC address from computer/server

橙三吉。 提交于 2019-12-25 18:57:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!