02. Network


Get IP details

Get IP address information
PS C:\> Get-NetIPAddress | Format-Table –Autosize

Get IP address information by the interface index
PS C:\> Get-NetIPAddress -InterfaceIndex 32

Get IP address information from pipeline input
PS C:\> Get-NetIPAddress | Sort-Object InterfaceIndex | Select-Object InterfaceIndex, InterfaceAlias, AddressFamily, IPAddress, PrefixLength | FT -Autosize



Get the IP configuration
PS C:\> Get-NetIPConfiguration –All | ft

Get the IP configuration from pipeline input
PS C:\> Get-NetIPConfiguration -all | Select-Object IPv4Address,InterfaceAlias,InterfaceDescription,InterfaceIndex | ft



Get all visible network adapters
PS C:\> Get-NetAdapter

Get all visible and hidden network adapters
PS C:\> Get-NetAdapter -Name "*" -IncludeHidden

Get all physical network adapters
PS C:\> Get-NetAdapter -Name "*" -Physical


Network Troubleshooting

Test ping connectivity

PowerShell version 6.x

PS C:\> Test-Connection 172.16.10.240
Pinging 172.16.10.240 [172.16.10.240] with 32 bytes of data:
Reply from 172.16.10.240: bytes=32 time=5ms TTL=254
Reply from 172.16.10.240: bytes=32 time=3ms TTL=254
Reply from 172.16.10.240: bytes=32 time=4ms TTL=254
Reply from 172.16.10.240: bytes=32 time=6ms TTL=254
Ping complete.

Source         Destination   Replies
------         -----------   -------
IN2-NOINB-RAVI 172.16.10.240 {System.Net.NetworkInformation.PingReply, System.Net.NetworkInformation.PingReply, System…

PS C:\> Test-Connection -ComputerName 172.16.10.240,172.16.10.241,172.16.10,247
PS C:\> Test-Connection -ComputerName 172.16.10.240 -Count 10 -Delay 3

Ping Multiple IPs from CSV

Import-Csv 'C:\ps\IP List.csv' | ForEach-Object {Test-Connection $_.IP_Address -Count 3}

CSV Template
S_No
IP_Address
1
172.16.10.240
2
172.16.10.241
3
172.16.10.242
4
172.16.10.6
5
172.16.10.243
6
172.16.10.244



PowerShell version 5.x

PS C:\> Test-Connection 172.16.10.240

Source        Destination     IPV4Address      IPV6Address                              Bytes    Time(ms)
------        -----------     -----------      -----------                              -----    --------
IN2-NOINB-... 172.16.10.240                                                             32       9
IN2-NOINB-... 172.16.10.240                                                             32       7
IN2-NOINB-... 172.16.10.240                                                             32       13
IN2-NOINB-... 172.16.10.240                                                             32       9


Test Open Port

PS C:\> Test-NetConnection -ComputerName 172.16.10.240 -Port 22 | Select-Object TcpTestSucceeded

For more details

Test-Connection
Test-NetConnection


Get more command

Check available command for network in windows
PS C:\> Get-Command -Module NetTCPIP



Post a Comment

0 Comments