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.
Step 1: Viewing Network Adapters
Section titled “Step 1: Viewing Network Adapters”List all network adapters on your system.
Get-NetAdapterStep 2: Assigning a Static IP Address
Section titled “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.1Step 3: Setting DNS Servers
Section titled “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
Section titled “Step 4: Enabling or Disabling a Network Adapter”Disable and then enable a network adapter.
Disable-NetAdapter -Name "Ethernet" -Confirm:$falseEnable-NetAdapter -Name "Ethernet"Step 5: Removing Static IP Configuration
Section titled “Step 5: Removing Static IP Configuration”Remove static IP settings to revert to DHCP.
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -Confirm:$falseSet-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp EnabledStep 6: Testing Network Configuration
Section titled “Step 6: Testing Network Configuration”Use the following command to test connectivity.
Test-Connection -ComputerName google.com -Count 4Conclusion
Section titled “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.