Powershell

30 Basic PowerShell Networking Commands

PowerShell is a scripting tool used by developers and IT professionals for task automation and configuration management. System administrators create customized scripts for program installation, user management, or file management.

Quick Outline:

What are Networking Commands in PowerShell

What is Computer Networking

30 Basic Powershell Networking Commands

Conclusion

What are Networking Commands in PowerShell?

PowerShell has a set of dedicated commands for every task. Similarly, PowerShell has a number of commands for network management. These networking commands perform tasks such as pinging the network, getting IP addresses, enabling or disabling the network adapter, testing a network connection, or clearing the network cache.

What is Computer Networking?

The term computer networking refers to interconnected computing devices in such a way that they can share resources and data with each other. These computing devices are connected to each other through physical wired cables or using wireless devices.

30 Basic Powershell Networking Commands

If you are a networking enthusiast and just started to learn networking then this article is for you. This article will cover the 30 most basic commands that are very useful when it comes to managing the network. All the networking commands will be explained with practical examples.

1. Ping

Ping cmdlet checks whether a server is accessible or not. It sends packet information to the server and waits for its return. If the packet data returns then that server is reachable. It cannot be contacted if it does not return the packet information. It then counts and displays the time consumed during sending and receiving packet information. It is like calling a friend on the cell phone and waiting for him to receive it.

This is how to ping a website or web server:

ping www.linuxhint.com

 

2. nslookup

The nslookup command looks up the DNS and gets the mapping between the IP address and domain name. For instance, the user provides the specific domain address to the nslookup command. In return, the user gets the IP address of that specified domain. Users can do a reverse domain look-up. For that, users need to enter the IP address of the domain and in return, they will get the domain name address.

This is how you can look for the domain address:

nslookup www.linuxhint.com

 

3. tracert

The tracert command tracks the route through which the IP packet traveled to the destination. It’s like checking the path through which a passenger traveled from one city to another. The tracert command counts the number of hops as well and determines the time each hop took. A hop is referred to as the event at which an IP packet is transferred from one device to another.

This is how you can trace the route of a domain:

tracert www.linuxhint.com

 

4. netstat

The netstat command determines the network and protocol statistics. It displays all active network connections, TCP and UDP endpoints, ports to which the system is listening, and routing tables. It is the all-in-one command to check all the network activities on Windows.

This is how you can check the active network connections statistics:

netstat

 

5. ipconfig

The ipconfig command displays the Windows IP configuration. It displays network adapters, IP addresses, subnet masks, DHCP, and DNS information. More importantly, it refreshes the DHCP server and DNS settings

This is how you can get the Windows IP configuration:

ipconfig

 

6. GetMac

The GetMac command gets the physical MAC address of all the connected network interfaces. This tool is very useful when you need to know each network adapter’s physical Mac address only.

This is how you can get the network adapters MAC address:

GetMac

 

7. HostName

The hostname command gets the name of the computer that is connected to the network. The hostname is the unique name assigned to the computer that is connected to the network. Hostnames are used to access a computer on the World Wide Web.

This is how you can determine the computer hostname:

hostname

 

8. FTP

The FTP command transfers the files from the local computer to the remote computer. It transfers files using the TCP network, such as the Internet. It lets you connect to the remote computer from your local computer.

This is how you can use the FTP command:

FTP

 

9. Get-NetRoute

The Get-NetRoute command gets the IP path or route information with the help of the IP routing table. It gets information like destination network prefixes and the IP address of the next hop. It is like finding a suitable path on the Google map to reach your destination.

Here is how you can display the IP route information:

Get-NetRoute

 

10. Get-NetAdapter

The Get-NetAdapter command gets the network adapter properties. Such as it displays the name, Mac address, link speed, status, ifIndex, and interface description of the network adapter. It gets the list of network adapters your computer is connected to.

This is how you can get the network adapter properties:

Get-NetAdapter

 

11. Get-NetAdapterHardwareInfo

The Get-NetAdapterHardwareInfo command gets the network adapter’s hardware information. It gets the list of the network adapters including Wi-Fi, and Ethernet. Furthermore, it gets the segment, bus, PcieLinkSpeed, PcieLinkWidth, and version information of the network adapter’s hardware.

Here is how you can get the network adapter’s hardware information:

Get-NetAdapterHardwareInfo

 

12. Rename-NetAdapter

The Rename-NetAdapter command renames the network adapter. Yes, the network adapter can be renamed to any desired name. For that purpose, check the mentioned command below.

This is how you can rename the network adapter:

Rename-NetAdapter -Name "Ethernet 4" -NewName "New Ethernet"

 

According to the above code:

  • First, place the Rename-NetAdapter command.
  • Then, write the existing name of the network adapter using the -Name parameter.
  • After that use the -NewName parameter and specify the new name of the network adapter:

13. Restart-NetAdapter

The Restart-NetAdapter command restarts the network adapter. When the network adapter starts to behave unusual, restarting it may help.

Here is how you can reboot the network adapter:

Restart-NetAdapter -Name "Ethernet 4"

 

According to the above code, first, use the Restart-NetAdapter, then assign the network adapter name using the -Name parameter:

14. Enable-NetAdapter

The Enable-NetAdapter command enables the network adapter (Wi-Fi, and Ethernet) if it is found disabled. It is a very useful utility to re-enable the disabled network adapter. A network adapter must be enabled in order to connect the computer to the internet.

Here is how you can enable the network adapter:

Enable-NetAdapter -Name "Ethernet 4"

 

According to the above code, first, use the Enable-NetAdapter, then specify the name of the network adapter using the -Name parameter:

15. Disable-NetAdapter

The Disable-NetAdapter command disables the network adapter such as Wi-Fi, and Ethernet. When a network adapter is disabled, it causes a loss of computer connectivity with the internet. Keep in mind, don’t disable the network adapter that your computer is using to connect to the internet.

Here is how you can disable the network adapter:

Disable-NetAdapter -Name "Ethernet 4"

 

According to the above code, first, use the Enable-NetAdapter, then specify the name of the network adapter using the -Name parameter:

16. Get-NetIPInterface

The Get-NetIPInterface command gets the IP interface of both IPv4 and IPv6 addresses. When this command is executed without parameters, it displays all the IP related configurations and interfaces including loop back and virtual interfaces.

This is how you can get the network IP interfaces:

Get-NetIPInterface

 

17. Get-NetIPAddress

The Get-NetIPAddress command gets the IP addressing information of your computer. It gets the IP address configurations including IPv4 and IPv6 addresses.

Here is how you can get the IP addressing information:

Get-NetIPAddress

 

18. Get-NetConnectionProfile

The Get-NetConnectionProfile command gets the network connection profile. It gets the connection profile that is linked to the network adapter.

This is how you can get the network connection profile:

Get-NetConnectionProfile

 

19. Test-Connection

The Test-Connection command is similar to the ping command. It pings one or more computers by sending the ICMP echo packet requests, and in return gets the echo replies.

This is how you can test a local or remote computer connection:

Test-Connection www.linuxhint.com

 

20. Test-NetConnection

The Test-NetConnection command displays the diagnostic information about a network connection. It provides information about the network such as RemoteAddress, InterfaceAlias, SourceAddress, PingSucceeded, and PingReplyDetails.

This is how you can get the diagnostic information about the network connection:

Test-NetConnection

 

21. Get-NetTCPConnection

The Get-NetTCPConnection command gets the current TCP connections. It gets the TCP connection properties including the IP address of local and remote computers, and the connection state. Its core purpose is to check the existing connections to the server.

This is how you can test the existing connections to your computer:

Get-NetTCPConnection

 

22. Get-DnsClient

The Get-DnsClient command gets the status of the DNS client. It retrieves the details of the network configured on the computer.

This is how you can get the status and configuration of the network specified to a computer:

Get-DnsClient

 

23. Get-DNSClientCache

The Get-DNSClientCache command gets the contents of the DNS client cache. A DNS client is a temporary storage information that keeps a record of all the recently visited websites.

Here is how you can get the client cache of the DNS:

Get-DNSClientCache

 

24. Clear-DnsClientCache

The Clear-DnsClientCache command clears the client’s DNS cache. There is no doubt that cache memory helps load web pages faster and enhances the overall web browsing experience. But, clearing the cache keeps you secure by resolving DNS errors.

This is how you can clear the client’s DNS cache:

Clear-DnsClientCache

 

25. Get-DNSClientServerAddress

The Get-DNSClientServerAddress command gets one or more server IP addresses that are associated with the computer interface. It gets the IP address from the TCP properties on the computer interface.

This is how you can get the server IP address on an interface:

Get-DNSClientServerAddress

 

26. Set-DnsClientServerAddress

The Set-DnsClientServerAddress command sets one or more IP addresses of DNS servers linked with the computer’s interface.

This is how you can set the customized DNS client server address:

Set-DnsClientServerAddress -InterfaceAlias "Ethernet/Wi-Fi" -ServerAddresses "2.2.2.2"

 

According to the above code, first, use the Set-DnsClientServerAddress command. Then, use the -InterfaceAlias parameter to assign the computer interface alias, and use the -ServerAddress parameter to assign the server address.

27. Resolve-Dnsname

The Resolve-Dnsname command performs the DNS query for the specified name. When a user provides it with the DNS name, then, in return it displays the IP address.

This is how you can resolve the DNS name:

Resolve-Dnsname www.linuxhint.com

 

28. Get-NetFirewallProfile

The Get-NetFirewallProfile command gets the configuration and status of the specified network firewall profile.

Here is how you can check the security status of the computer:

Get-NetFirewallProfile

 

29. Get-NetNeighbor

The Get-NetNeighbor command gets the neighbor cache entries. It is like obtaining information from your neighbor and telling it to someone worthy.

Here is how you can get the neighbor cache entries:

Get-NetNeighbor

 

30. Get-NetIPConfiguration

The Get-NetIPConfiguration command gets the IP network configuration. It gets the IP address, DNS server, and interface of the network.

This is how you can get the network IP configuration:

Get-NetIPConfiguration

 

Conclusion

The Networking term refers to the computers that are interconnected. Network administrators usually have the GUI (Graphical User Interface) for network management. However, network administrators can use the PowerShell to manage the network. To manage the network using PowerShell, administrators must be aware of the networking commands. These commands include ping, tracert, nslookup, Get-NetRoute, or netstat.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.