The following is a PowerShell script to quickly hard code DNS servers for every network interface present on a computer. It will overwrite the existing DNS servers configured on that machines interfaces. In this example, we'll be using the IP addresses for OpenDNS servers.
# The servers that we want to use
$newDNSServers = "208.67.220.220","208.67.222.222"
# Get all network adapters that already have DNS servers set
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DNSServerSearchOrder -ne $null}
# Set the DNS server search order for all of the previously-found adapters
$adapters | ForEach-Object {$_.SetDNSServerSearchOrder($newDNSServers)}
Hard Code DNS Servers with PowerShell
May 14, 2016 with No commentsIn DNS, PowerShell, Windows on
0 comments:
Post a Comment
Discuss this post!