Skip to content

Configuring Network Settings with PowerShell

This article provides a concise guide on how to configure network settings using PowerShell on Windows.

Using PowerShell for network configuration allows automation, consistency, and speed—ideal for system administrators managing multiple systems or remote environments.

List all network adapters on your system.

Terminal window
Get-NetAdapter

Set a static IP address, subnet mask, and default gateway.

Terminal window
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1

Configure the preferred and alternate DNS servers.

Terminal window
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("8.8.8.8", "8.8.4.4")

Step 4: Enabling or Disabling a Network Adapter

Section titled “Step 4: Enabling or Disabling a Network Adapter”

Disable and then enable a network adapter.

Terminal window
Disable-NetAdapter -Name "Ethernet" -Confirm:$false
Enable-NetAdapter -Name "Ethernet"

Remove static IP settings to revert to DHCP.

Terminal window
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -Confirm:$false
Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled

Use the following command to test connectivity.

Terminal window
Test-Connection -ComputerName google.com -Count 4

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.