PowerShell is a powerful tool for managing network settings. With many cmdlets, you can list network adapters, check connection statuses, configure IP addresses, and more. We'll look at the basics.
Gathering Network Information
The Get-NetIPAddress cmdlet allows you to retrieve IP address information and other IP configuration details assigned to a computer's network interfaces.
Get-NetIPAddress
Other commands that can be used are legacy tools from CMD that are still in use.
IPConfig
Short for "Internet Protocol Configuration," this command is used to display IP configuration information for network connections. It lists IP addresses, subnet masks, default gateways, and other network configuration details assigned to the computer's current network connections.
A tool used to display network connections for the TCP/IP protocol, routing tables, and network interface statistics.
Nslookup
A tool used to query the DNS (Domain Name System) to obtain domain name or IP address mapping details. It is used to find the IP address corresponding to a given domain name.
ARP
Short for Address Resolution Protocol, this protocol is used to map IP addresses to physical MAC addresses in a network. The ARP command manages the ARP cache and lists the entries in this cache.
Testing Connections
The Test-NetConnection cmdlet is used to test the status of a network connection by pinging a computer.
Downloading Files
Invoke-WebRequest is a cmdlet used to interact with web pages and web services. It allows you to send HTTP/HTTPS requests and receive data or perform actions on these web resources.
To download a file, you can use the command as follows:
Here, the -Uri parameter specifies the web address and the -OutFilep arameter specifies the file name to save the file as.
PS C:\> netstat
Active Connections
Proto Local Address Foreign Address State
TCP 10.0.2.15:62553 SRV2019:domain TIME_WAIT
TCP [::1]:389 SRV2019:49531 ESTABLISHED
TCP [::1]:389 SRV2019:49551 ESTABLISHED
TCP [::1]:389 SRV2019:49558 ESTABLISHED
TCP [::1]:389 SRV2019:49677 ESTABLISHED
TCP [::1]:389 SRV2019:49678 ESTABLISHED
TCP [::1]:389 SRV2019:49683 ESTABLISHED
TCP [::1]:49531 SRV2019:ldap ESTABLISHED
TCP [::1]:49551 SRV2019:ldap ESTABLISHED
...