Network troubleshooting with Powershell

Network troubleshooting with Powershell

Knowing how to troubleshoot network issues is a fundamental skill to all IT professionals. Usually in computers with Windows operating systems this task was delegated to CMD (Command Line), with commands like PING, TELNET or IPCONFIG.

Note: 90% of the network commands from CMD are compatible with Powershell.

Get-NetAdapter

Shows all the available network adapters and their MAC addresses

Get-NetAdapter | Where-Object {$_.Status -eq “up”}

Retrieves the adapters with active connection

Get-NetIPAddress

Equivalent of IPCONFIG but it will retrieve the IPv6 and IPv4 address families

Get-NetIPAddress | Where-Object {$_.PrefixOrigin -eq “dhcp”} | Select-Object -Property IPAddress, InterFaceAlias

To know which interfaces have DHCP

Get-NetIPAddress | select InterfaceAlias,IPAddress,AddressFamily,PrefixOrigin |Where-Object {$_.AddressFamily -eq ‘IPv4’}

Command will filter IPv4

Test-NetConnection “URL”

Equivalent to PING

Test-NetConnection “URL” -Traceroute

Equivalent to TRACEROUTE

Resolve-DnsName -Name “URL”

Gets the IP

Get-NetTCPConnection

Displays the IPs and Ports and their state