In this post, we will provide a PowerShell script that automates the configuration of network settings on Windows machines. Proper network configuration is vital for ensuring seamless connectivity and optimal performance. This script allows IT administrators to quickly set static IP addresses, configure DNS servers, and display the current network settings, simplifying the management of network configurations across multiple devices. Here is the PowerShell script for network configuration:
# Define network settings
$interfaceAlias = "Ethernet"
$staticIP = "192.168.1.100"
$subnetMask = "255.255.255.0"
$defaultGateway = "192.168.1.1"
$dnsServers = @("8.8.8.8", "8.8.4.4")
# Set a static IP address
New-NetIPAddress -InterfaceAlias $interfaceAlias -IPAddress $staticIP -PrefixLength 24 -DefaultGateway $defaultGateway
# Set DNS servers
Set-DnsClientServerAddress -InterfaceAlias $interfaceAlias -ServerAddresses $dnsServers
# Display current network configuration
Get-NetIPAddress -InterfaceAlias $interfaceAlias | Format-Table -AutoSize
Get-DnsClientServerAddress -InterfaceAlias $interfaceAlias | Format-Table -AutoSize
Write-Host "Network configuration has been updated successfully."Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
Ready when you are.
Try ServerEngine free for 7 days.