Name NetworkInterfaceType Description ----------------------------------- vEthernet (Default Switch) Ethernet Hyper-V Virtual Ethernet Adapter Ethernet 2 Ethernet USB Ethernet Local Area Connection* 1 Wireless80211 Microsoft Wi-Fi Direct Virtual Adapter Local Area Connection* 2 Wireless80211 Microsoft Wi-Fi Direct Virtual Adapter #2 WLAN Wireless80211 Killer(R) Wi-Fi6 AX1650s 160MHz Wireless Network Adapter (201D2W) Bluetooth Network Connection Ethernet Bluetooth Device (Personal Area Network) Loopback Pseudo-Interface1 Loopback Software Loopback Interface 1
但是,您找到的.NET方法可能不直接包含所需信息。在我们的示例中,GetAllNetworkInterfaces() 返回所有网络适配器,但要获取它们的 MAC 地址,则需要深入了解 .NET 对象树。这就使得使用这种技术变得更加困难(但也令人兴奋和有益)。
Name Status Mac SpeedGb -------------------- vEthernet (Default Switch) Up 00-15-5D-58-46-A810 Ethernet 2 Up 80-3F-5D-05-58-911 Local Area Connection* 1 Down 24-EE-9A-54-1B-E6 Local Area Connection* 2 Down 26-EE-9A-54-1B-E5 WLAN Down 24-EE-9A-54-1B-E50,78 Bluetooth Network Connection Down 24-EE-9A-54-1B-E90,003
1..255 | ForEach-Object { # create the IP address to ping # make sure you adjust this to your segment! $ip = "192.168.2.$_" # execute ping.exe and disregard the text output ping -n1-w500$ip > $null # instead return the translated return value found in $LASTEXITCODE [PSCustomObject]@{ IpAddress = $ip Status = $translation[$LASTEXITCODE] } }