Search notes:

ip.ps1 - Print IP Addresses of local non-loopback network interfaces.

ip.ps1 is a PowerShell script that prints the IP Address of local non-loopback network interfaces.
#
# Print IP addresses of local network interfaces.
# Inpsired by https://github.com/Treer/ip4
#
# V1
#
#
# Adapter is another word for network interface.
#
$adapters = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()

foreach ($adapter in $adapters) {
   '{0,-30} {1,-20} {2}' -f $adapter.name, $adapter.networkInterfaceType, $adapter.operationalStatus

   foreach ($addressInfo in $adapter.GetIPProperties().UnicastAddresses) {

      $address = $addressInfo.Address

      if ( # Skip loopback addresses, non IP V4 (Internetwork) and non IP V6 (InternetworkV6)

        ( -not [System.Net.IPAddress]::IsLoopback($address)                                                 ) -and
        ( $adapter.NetworkInterfaceType -ne  [System.Net.NetworkInformation.NetworkInterfacetype]::Loopback ) -and
        ( $address.AddressFamily        -in ([System.Net.Sockets.AddressFamily]::Internetwork,
                                             [System.Net.Sockets.AddressFamily]::InternetworkV6)            )
      ) {

        "  $($address.IPAddressToString)"

      }
   }
}
Github repository scripts-and-utilities, path: /ip.ps1

See also

Other Scripts

Links

This script was inspired by https://github.com/Treer/ip4

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390647, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/tools/scripts/personal/ip_ps1(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78