How to Configure Network Settings with PowerShell on Windows Server 2025
Configuring network settings through the GUI on Windows Server 2025 is fine for one-off tasks, but any serious production environment demands scriptable, repeatable, and auditable network configuration. PowerShell’s NetAdapter, NetTCPIP, NetLbfo, and DnsClient modules provide a comprehensive, consistent interface for managing every aspect of Windows Server networking — from basic IP assignment to NIC teaming, static routing, and connection profile management. This tutorial walks through the complete PowerShell-first approach to network configuration on Windows Server 2025, covering adapter management, static IP assignment, DNS configuration, routing, NIC teaming, and connectivity testing. Legacy netsh equivalents are provided for reference, but PowerShell cmdlets are the recommended path for all new automation.
Prerequisites
- Windows Server 2025 (any edition, including Server Core)
- Administrator privileges
- PowerShell 5.1 or PowerShell 7.x
- At least one physical or virtual network adapter visible to the OS
- For NIC teaming: two or more network adapters on the same switch or with appropriate LACP support
Step 1: Discover Network Adapters
Before changing any network settings, enumerate the adapters available on the server:
# List all network adapters with status and speed
Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, LinkSpeed, MacAddress
# Show only connected (Up) adapters
Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
# Get detailed hardware information for an adapter
Get-NetAdapter -Name "Ethernet0" | Get-NetAdapterHardwareInfo
# Get adapter statistics (packets sent/received, errors)
Get-NetAdapterStatistics -Name "Ethernet0"
Note the Name field (e.g., “Ethernet0”, “Ethernet 2”) — this is the interface alias and is what all subsequent cmdlets use to reference adapters.
Step 2: Rename Network Adapters
Adapter names are auto-generated and often meaningless (Ethernet, Ethernet 2). Rename them to reflect their function before configuring anything else:
# Rename adapters for clarity
Rename-NetAdapter -Name "Ethernet" -NewName "Management"
Rename-NetAdapter -Name "Ethernet 2" -NewName "Production"
Rename-NetAdapter -Name "Ethernet 3" -NewName "Storage"
# Verify
Get-NetAdapter | Select-Object Name, Status, LinkSpeed
Meaningful adapter names make all subsequent scripts and firewall rules self-documenting.
Step 3: Assign a Static IP Address
Use New-NetIPAddress to assign a static IPv4 or IPv6 address. First, remove any existing DHCP-assigned address:
# View current IP configuration
Get-NetIPAddress -InterfaceAlias "Management" | Select-Object InterfaceAlias, IPAddress, PrefixLength, AddressFamily
# Remove any existing IP addresses on the adapter
Remove-NetIPAddress -InterfaceAlias "Management" -Confirm:$false
# Remove any existing default gateway (if set via DHCP)
Remove-NetRoute -InterfaceAlias "Management" -DestinationPrefix "0.0.0.0/0" -Confirm:$false -ErrorAction SilentlyContinue
# Assign a new static IP with default gateway
New-NetIPAddress `
-InterfaceAlias "Management" `
-IPAddress "10.10.0.50" `
-PrefixLength 24 `
-DefaultGateway "10.10.0.1"
# Assign a static IP to the Production adapter (no gateway — gateway only on Management)
New-NetIPAddress `
-InterfaceAlias "Production" `
-IPAddress "192.168.10.50" `
-PrefixLength 24
Avoid assigning a default gateway to multiple adapters — this causes asymmetric routing issues. One adapter (typically the management or internet-facing one) gets the gateway; others get only the IP and subnet.
Step 4: Configure DNS Client Settings
# Set DNS servers on the Management adapter
Set-DnsClientServerAddress `
-InterfaceAlias "Management" `
-ServerAddresses "10.10.0.10", "10.10.0.11"
# Verify DNS settings
Get-DnsClientServerAddress -InterfaceAlias "Management"
# Set the DNS search suffix list
Set-DnsClient -InterfaceAlias "Management" -ConnectionSpecificSuffix "contoso.local"
# Set global DNS suffix search list (applies to all adapters)
Set-DnsClientGlobalSetting -SuffixSearchList "contoso.local", "corp.contoso.com"
# Flush DNS client cache after changes
Clear-DnsClientCache
# Verify DNS resolution is working
Resolve-DnsName "dc01.contoso.local"
Step 5: Manage Static Routes
Static routes are needed when traffic to specific subnets must go through a non-default gateway:
# View the current routing table
Get-NetRoute | Where-Object {$_.AddressFamily -eq "IPv4"} |
Select-Object DestinationPrefix, NextHop, RouteMetric, InterfaceAlias |
Sort-Object DestinationPrefix
# Add a persistent static route for the 172.16.0.0/16 network via a specific gateway
New-NetRoute `
-DestinationPrefix "172.16.0.0/16" `
-InterfaceAlias "Production" `
-NextHop "192.168.10.1" `
-RouteMetric 10 `
-PolicyStore PersistentStore
# Remove a static route
Remove-NetRoute -DestinationPrefix "172.16.0.0/16" -Confirm:$false
# Legacy netsh equivalent for reference:
# netsh interface ipv4 add route 172.16.0.0/16 "Production" 192.168.10.1
Step 6: Configure the Network Connection Profile
Windows assigns each connection a profile (Domain, Private, or Public) which affects firewall rules. On a server, you generally want domain-joined adapters in the Domain profile:
# View current connection profiles
Get-NetConnectionProfile | Select-Object InterfaceAlias, NetworkCategory, IPv4Connectivity, IPv6Connectivity
# Change a profile (e.g., if auto-detection placed it in Public)
Set-NetConnectionProfile -InterfaceAlias "Management" -NetworkCategory Private
# Force domain-authenticated profile (requires the adapter to actually reach a DC)
Set-NetConnectionProfile -InterfaceAlias "Management" -NetworkCategory DomainAuthenticated
Step 7: Configure NIC Teaming (LBFO)
NIC teaming on Windows Server 2025 combines multiple physical adapters into a single logical interface for load balancing and/or failover. Use New-NetLbfoTeam to create a team:
# Create a Switch Independent team with Dynamic load balancing (recommended for non-LACP environments)
New-NetLbfoTeam `
-Name "ProductionTeam" `
-TeamMembers "Production", "Production2" `
-TeamingMode SwitchIndependent `
-LoadBalancingAlgorithm Dynamic
# Create an LACP (802.3ad) team for switch-assisted load balancing
New-NetLbfoTeam `
-Name "StorageTeam" `
-TeamMembers "Storage", "Storage2" `
-TeamingMode LACP `
-LacpTimer Fast `
-LoadBalancingAlgorithm TransportPorts
# View team status
Get-NetLbfoTeam | Select-Object Name, Status, TeamingMode, LoadBalancingAlgorithm
Get-NetLbfoTeamMember | Select-Object Name, Team, AdministrativeMode, OperationalMode
# Assign an IP to the team interface
New-NetIPAddress `
-InterfaceAlias "ProductionTeam" `
-IPAddress "192.168.10.50" `
-PrefixLength 24
# Remove a team
Remove-NetLbfoTeam -Name "ProductionTeam" -Confirm:$false
After creating a team, the member adapters lose their individual IP addresses. Assign the IP to the new team interface instead.
Step 8: Configure Adapter Advanced Properties
# Enable Jumbo Frames (9014 bytes) for storage adapters — improves iSCSI/SMB performance
Set-NetAdapterAdvancedProperty `
-Name "Storage" `
-DisplayName "Jumbo Packet" `
-DisplayValue "9014 Bytes"
# Disable Energy Efficient Ethernet (EEE) — prevents latency spikes
Set-NetAdapterAdvancedProperty `
-Name "Management" `
-DisplayName "Energy-Efficient Ethernet" `
-DisplayValue "Disabled"
# Enable Receive Side Scaling (RSS) for multi-core packet processing
Enable-NetAdapterRss -Name "Production"
Set-NetAdapterRss -Name "Production" -NumberOfReceiveQueues 4
# View all advanced properties for an adapter
Get-NetAdapterAdvancedProperty -Name "Management" | Select-Object DisplayName, DisplayValue
Step 9: Test Connectivity with Test-NetConnection
Test-NetConnection replaces both ping and telnet for connectivity testing in PowerShell. It tests ICMP reachability and TCP port connectivity:
# Basic ICMP ping test
Test-NetConnection -ComputerName "dc01.contoso.local"
# Test TCP port connectivity (replaces telnet for port testing)
Test-NetConnection -ComputerName "sqlserver01.contoso.local" -Port 1433
Test-NetConnection -ComputerName "webserver01.contoso.local" -Port 443
Test-NetConnection -ComputerName "10.10.0.10" -Port 3389
# Test with detailed output including route and source interface
Test-NetConnection -ComputerName "8.8.8.8" -InformationLevel Detailed
# Batch port test across multiple servers
$servers = @("dc01", "dc02", "fileserver01")
$servers | ForEach-Object {
$result = Test-NetConnection -ComputerName $_ -Port 445 -WarningAction SilentlyContinue
[PSCustomObject]@{
Server = $_
Port445 = $result.TcpTestSucceeded
RTT = $result.PingReplyDetails.RoundtripTime
}
}
Step 10: Complete Network Configuration Script Template
Here is a complete, reusable script that applies a full static network configuration — suitable for inclusion in a server build automation pipeline:
#Requires -RunAsAdministrator
# Network Configuration Script for Windows Server 2025
# Usage: Run once during server provisioning
$config = @{
ManagementAlias = "Management"
ManagementIP = "10.10.0.50"
ManagementPrefix = 24
DefaultGateway = "10.10.0.1"
PrimaryDNS = "10.10.0.10"
SecondaryDNS = "10.10.0.11"
DNSSuffix = "contoso.local"
}
# Remove existing configuration
Remove-NetIPAddress -InterfaceAlias $config.ManagementAlias -Confirm:$false -ErrorAction SilentlyContinue
Remove-NetRoute -InterfaceAlias $config.ManagementAlias -DestinationPrefix "0.0.0.0/0" -Confirm:$false -ErrorAction SilentlyContinue
# Apply static IP
New-NetIPAddress `
-InterfaceAlias $config.ManagementAlias `
-IPAddress $config.ManagementIP `
-PrefixLength $config.ManagementPrefix `
-DefaultGateway $config.DefaultGateway
# Apply DNS
Set-DnsClientServerAddress `
-InterfaceAlias $config.ManagementAlias `
-ServerAddresses $config.PrimaryDNS, $config.SecondaryDNS
# Set DNS suffix
Set-DnsClient -InterfaceAlias $config.ManagementAlias -ConnectionSpecificSuffix $config.DNSSuffix
# Flush cache and verify
Clear-DnsClientCache
Write-Host "IP Configuration:" -ForegroundColor Green
Get-NetIPAddress -InterfaceAlias $config.ManagementAlias
Write-Host "DNS Configuration:" -ForegroundColor Green
Get-DnsClientServerAddress -InterfaceAlias $config.ManagementAlias
Write-Host "Connectivity test:" -ForegroundColor Green
Test-NetConnection -ComputerName $config.PrimaryDNS -InformationLevel Quiet
Conclusion
PowerShell provides a complete, consistent, and scriptable interface for all network configuration tasks on Windows Server 2025. By using Get-NetAdapter and Rename-NetAdapter to establish a meaningful naming convention, New-NetIPAddress and Remove-NetIPAddress for precise IP management, Set-DnsClientServerAddress for DNS, New-NetRoute for static routing, New-NetLbfoTeam for NIC teaming, and Test-NetConnection -Port for connectivity validation, you create network configurations that are repeatable, auditable, and version-controllable. Avoid the GUI and legacy netsh for new automation — PowerShell cmdlets persist settings correctly, are idempotent when combined with remove-before-add patterns, and integrate cleanly into deployment pipelines, DSC configurations, and infrastructure-as-code workflows.