Network queries

# get the network configuration
   netsh interface ipv4 show interfaces
   wmic nic get AdapterType, Name, Installed, MACAddress, NetConnectionStatus, Speed
   wmic path Win32_NetworkAdapter where NetConnectionID="Ethernet" get Name, MACAddress, NetConnectionStatus

# get information about all network adapters
   get-wmiobject win32_networkadapter | format-table -auto
# or
   Get-NetAdapter | format-table -auto
# or
   Get-NetAdapter -physical | format-table -auto

# get all connected adapters
   get-wmiobject win32_networkadapter -filter "netconnectionstatus = 2" | format-table -auto
# or
   Get-NetAdapterHardwareInfo -Name "*" | Format-List -Property "*"

#
   get-wmiobject win32_networkadapter -filter "netconnectionstatus = 2" | select netconnectionid, name, InterfaceIndex, netconnectionstatus

   [System.Net.Dns]::GetHostByName($Computer).AddressList[0].IpAddressToString
   Get-NetAdapter | where Status -eq 'Up'
   Get-NetIPConfiguration

???
   $IP_CONFIG1 = Get-NetAdapter | where Status -eq 'Up' | select ifIndex
   Get-NetIPConfiguration | where InterfaceIndex -eq IP_CONFIG1

# get IP and MACIP from connected Network
   (get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}).IPAddress | Select-object -index 0
   (Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.ipenabled -EQ $true}).Macaddress | select-object -first 1

###############################
Get-WmiObject win32_networkadapterconfiguration |
Select-Object -Property @{
    Name = 'IPAddress'
    Expression = {($PSItem.IPAddress[0])}
},MacAddress |
Where IPAddress -NE $null
###############################
$Data = @()
$NetInfo = Get-NetIPConfiguration -Detailed
foreach ( $nic in $Netinfo) {
    foreach ($ip in $nic.IPv4Address) {
        $Data += [pscustomobject] @{ Ordinateur=$nic.ComputerName; AliasNIC=$nic.InterfaceAlias;
                                    NetworkcardName=$nic.InterfaceDescription; IP=$ip; MAC=$nic.NetAdapter.MACAddress;
                                    Status=$nic.NetAdapter.Status
                                    }
    }
 }
 $Data | Format-Table #-HideTableHeader
###############################

# get route
   Get-NetRoute –DestinationPrefix "0.0.0.0/0" | Select-Object –ExpandProperty "NextHop"

# get dns
   Get-DnsClientServerAddress -InterfaceIndex 13