Asked by:
How to get powershell to display only the interface alias and IP address

Question
-
Hi can somebody help
i have run a script which changes the -interface name and sets ip address but i now want to check the name of the adaptor and the IP address are correct. i have tried to use various examples and also piping through from one function
below are some simple commands that i can use but i can't work out how to combine any help greatly appreciated
I can use
PS C:\Windows\system32> get-Netadapter | get-Netipaddress | Format-table ifIndex IPAddress PrefixLength PrefixOrigin SuffixOrigin AddressState PolicyStore ------- --------- ------------ ------------ ------------ ------------ ----------- 66 fe80::dc2e:7d51:e01b:6d1b%66 64 WellKnown Link Deprecated ActiveStore 66 169.254.109.27 16 WellKnown Link Tentative ActiveStore 60 fe80::8963:5f37:4a1f:9afc%60 64 WellKnown Link Deprecated ActiveStore 60 172.22.32.1 27 Manual Manual Tentative ActiveStore 60 169.254.154.252 16 WellKnown Link Tentative ActiveStore 25 fe80::a50a:7a1c:3f49:f5df%25 64 WellKnown Link Deprecated ActiveStore 25 169.254.245.223 16 WellKnown Link Tentative ActiveStore 25 169.254.2.1 23 Manual Manual Tentative ActiveStore 25 169.254.1.1 23 Manual Manual Tentative ActiveStore 39 fe80::4c52:9107:fa8c:eb00%39 64 WellKnown Link Deprecated ActiveStore 39 169.254.235.0 16 WellKnown Link Tentative ActiveStore 21 fe80::c059:d2f1:5cec:f910%21 64 WellKnown Link Preferred ActiveStore 21 192.168.3.1 27 Manual Manual Preferred ActiveStore 72 fe80::60e7:8001:9fa7:b080%72 64 WellKnown Link Deprecated ActiveStore 75 fe80::e86f:786b:3a49:ba98%75 64 WellKnown Link Deprecated ActiveStore 72 169.254.176.128 16 WellKnown Link Tentative ActiveStore 72 20.20.20.1 24 Manual Manual Tentative ActiveStore 75 169.254.186.152 16 WellKnown Link Tentative ActiveStore 8 fe80::b4e4:5199:3074:7db%8 64 WellKnown Link Preferred ActiveStore 8 192.168.248.1 23 Manual Manual Preferred ActiveStore 14 fe80::3ceb:65cb:1e1:aa57%14 64 WellKnown Link Preferred ActiveStore 14 192.168.213.1 24 Manual Manual Preferred ActiveStore 4 fe80::5133:490b:9810:6fa%4 64 WellKnown Link Preferred ActiveStore 27 fe80::f9ea:de09:bce6:5c0b%27 64 WellKnown Link Deprecated ActiveStore 4 169.254.6.250 16 WellKnown Link Preferred ActiveStore 27 169.254.92.11 16 WellKnown Link Tentative ActiveStore 15 fe80::a879:7f64:4039:5301%15 64 WellKnown Link Preferred ActiveStore 15 192.168.181.1 24 Manual Manual Preferred ActiveStore
Which outputs the address and IF index
and i can use the Get-Netadpator
PS C:\Windows\system32> get-Netadapter -name "$localName1" Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Onboard_A_SCADA_Route1 Intel(R) Ethernet Connection (2) I21... 22 Disconnected 00-30-A7-21-2D-3D 0 bps PS C:\Windows\system32> get-Netadapter -name "$localName1,$localName2" PS C:\Windows\system32> get-Netadapter -name "$localName1","$localName2" Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Onboard_B_SCADA_Route2 Intel(R) I210 Gigabit Network Connec... 24 Disconnected 00-30-A7-21-2D-3E 0 bps Onboard_A_SCADA_Route1 Intel(R) Ethernet Connection (2) I21... 22 Disconnected 00-30-A7-21-2D-3D 0 bps
Is there a way to use a pipe or other way to get the Get-netadaptor to show both the -name and also Get-NetIpaddress and then output to a table format
PS C:\Windows\system32> get-Netadapter -Name "*" | Format-List -property "name", "Ipaddress" name : TEAM_PCI5 _(B)-PCI5_(C)_61850_Mirror name : TEAM_PCI4_(C)-PCI4_(D)_OTN_Copadata name : TEAM-PCI4_(A)-PCI4_(B)-SCADA Mirror name : TEAM_Onboard_A-Onboard_B_Scada name : Onboard_B_SCADA_Route2 name : PCI5_(A)_OTN_MNGT name : PCI5 _(B)_61850_Mirror_Red name : PCI5_(C)_61850_Mirror_Black name : PCI5_(D)_ENG_Access name : PCI3_(B)_Diag_Station_Gaurd name : PCI4_(A)_SCADA_Mirror_Route1 name : PCI4_(B)-SCADA_Mirror_Route2 name : PCI4_(C)_Copadata_Route 1 name : PCI4_(D)_Copadata_Route 2 name : PCI3_(A)_Diag_Station_Scout name : PCI2_PCI-e-61850_PRP name : VMware Network Adapter VMnet8 name : VMware Network Adapter VMnet1 name : Ethernet 3 name : Onboard_A_SCADA_Route1
thank you for your time i am looking forward to somebody how simple this is properly to do
Monday, May 11, 2020 11:52 AM
All replies
-
as i get your question you may need something like this:
get-Netipaddress | select IPAddress,InterfaceAlias
or this:
Get-NetAdapter -Name * | foreach {$NAN = $_.Name ; Get-NetIPAddress -InterfaceIndex $_.ifIndex | Select IpAddress, @{n = 'NetAdapterName';e={$NAN}}}
The opinion expressed by me is not an official position of Microsoft
- Proposed as answer by GouravIN Monday, May 11, 2020 1:37 PM
Monday, May 11, 2020 1:14 PM