Wandering Journey

Jounaling the travel from one subject to another, often with no definite destination or purpose...

Powershell: One line from command prompt

11 January 2021

One liner to enumerate IP addresses

powershell -command "&  {get-netipaddress | where-object {$_.AddressFamily -eq 'IPv4'} | Select-object InterfaceAlias, IPAddress, AddressFamily} | ConvertTo-JSON"
[
    {
        "InterfaceAlias":  "Ethernet 5",
        "IPAddress":  "169.254.19.127",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Ethernet 5",
        "IPAddress":  "10.150.15.113",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Ethernet 3",
        "IPAddress":  "169.254.215.81",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Ethernet 2",
        "IPAddress":  "169.254.159.87",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Bluetooth Network Connection",
        "IPAddress":  "169.254.55.138",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Ethernet0",
        "IPAddress":  "192.168.106.128",
        "AddressFamily":  2
    },
    {
        "InterfaceAlias":  "Loopback Pseudo-Interface 1",
        "IPAddress":  "127.0.0.1",
        "AddressFamily":  2
    }
]