What
This article provides a concise guide on how to configure network settings using PowerShell on Windows.
Why
Using PowerShell for network configuration allows automation, consistency, and speed—ideal for system administrators managing multiple systems or remote environments.
How
Step 1: Viewing Network Adapters
List all network adapters on your system.
Get-NetAdapter
Step 2: Assigning a Static IP Address
Set a static IP address, subnet mask, and default gateway.
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Step 3: Setting DNS Servers
Configure the preferred and alternate DNS servers.
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("8.8.8.8", "8.8.4.4")
Step 4: Enabling or Disabling a Network Adapter
Disable and then enable a network adapter.
Disable-NetAdapter -Name "Ethernet" -Confirm:$false
Enable-NetAdapter -Name "Ethernet"
Step 5: Removing Static IP Configuration
Remove static IP settings to revert to DHCP.
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -Confirm:$false
Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled
Step 6: Testing Network Configuration
Use the following command to test connectivity.
Test-Connection -ComputerName google.com -Count 4
Conclusion
PowerShell provides a powerful and efficient way to manage network settings on Windows. By mastering these commands, administrators can streamline network configuration tasks and ensure systems remain consistent and compliant.