Simplify Network Configuration with PowerShell
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."