Empty Coder
Empty Coder

Reputation: 589

parsing ipconfig /all output to get only Ethernet records

Below is the output I am getting from my ipconfig /all command

PS C:\Windows\system32> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : XXXXXXXX
   Primary Dns Suffix  . . . . . . . : XXXXXX
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : XXXX.XXX.XXX.XX
                                       XX.XXX.XXX

Ethernet adapter PROD:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : vmxnet3 Ethernet Adapter #2
   Physical Address. . . . . . . . . : 00-50-56-8B-CA-B3
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 1.1.9.7(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.224
   Default Gateway . . . . . . . . . : 1.124.0.5
   DNS Servers . . . . . . . . . . . : 10.255.255.10
                                       10.0.0.10
   NetBIOS over Tcpip. . . . . . . . : Disabled


Ethernet adapter Backup:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : vmxnet3 Ethernet Adapter
   Physical Address. . . . . . . . . : 00-50-56-8B-9C-C6
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 10.5.35.2(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.252.0
   Default Gateway . . . . . . . . . :
   NetBIOS over Tcpip. . . . . . . . : Disabled


Tunnel adapter isatap.{ED18D3B3-5B05-451B-A0D2-AEEBB251E77A}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft ISATAP Adapter
   Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes

I want to get only the Ethernet details from this output

Something like starting from Ethernet and ending Tunnel. line between these 2 words

I was tried using netsh and grep, but not able to get the output Please need some help how to do this.

Upvotes: 0

Views: 1389

Answers (1)

Hazrelle
Hazrelle

Reputation: 856

You should review the 3 following cmdlets:

  • Get-NetAdapter (return ifIndex)
  • Get-NetIPAddress (return InterfaceIndex)
  • Get-NetIPConfiguration (return InterfaceIndex)

Combining all the three should give you what you expect.

Upvotes: 1

Related Questions