This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import struct | |
| import sys | |
| import json # Importing json module for JSON formatting | |
| def byte_to_int(b): | |
| """Handles byte to integer conversion for Python 2 and 3 compatibility.""" | |
| return ord(b) if isinstance(b, str) else b | |
| def mac_address_format(byte_sequence): | |
| """Format MAC address bytes for both Python 2 and 3.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Discover things and create an $Entries object. | |
| $NetworkInterfaces = Get-NetIPInterface -AddressFamily IPv4 | Where-Object ConnectionState -EQ 'Connected' | Where-Object NlMtu -LT 9001 | |
| $DNSServerAddresses = Get-DnsClientServerAddress -AddressFamily IPv4 | |
| $DNSClients = Get-DnsClient | |
| $Entries = $NetworkInterfaces | ForEach-Object { | |
| [PSCustomObject]@{ | |
| 'InterfaceAlias' = $_.InterfaceAlias | |
| 'InterfaceIndex' = $_.InterfaceIndex | |
| 'InterfaceMetric' = $_.InterfaceMetric |