从计算机/服务器获取有线MAC地址 [英] Get wired MAC address from computer/server

查看:107
本文介绍了从计算机/服务器获取有线MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将有线MAC-adr用作程序中的唯一值.因此,我需要确保MAC-adr是有线的,而不是无线的.

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

这是我开始的目的,但是它给了我两个地址. 第一个是我想要的一个:00:00:11:11:22:22 最后一个是无线地址:00:1F:3C:8E:61:D8

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

我不能像这样排序:选择-first 1.因为我不知道这会导致我在其他计算机上工作. 顺便说一句,这个功能在ipV6和ipV4上都可以使用吗?

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?

推荐答案

尝试这种方式:

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

如果有多个,则需要进行选择.

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

这篇关于从计算机/服务器获取有线MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆