- foreach ($nic in [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()) {
- if ($nic.NetworkInterfaceType -ne 'Loopback' -and $nic.OperationalStatus -eq 'Up') {
- $ipprops = $nic.GetIPProperties()
- foreach ($ipinfo in $ipprops.UnicastAddresses) {
- if ($ipinfo.PrefixOrigin -eq 'RouterAdvertisement' -and $ipinfo.SuffixOrigin -eq 'LinkLayerAddress') {
- $ipinfo.Address.ToString()
- }
- }
- }
- }
复制代码
|