I frequently use custom DNS settings in my lab environments to override the provided DHCP settings and use my own personal domain controllers.
For Server 2008 I used the following commands:
netsh interface ipv4 add dnsserver "local area connection" x.x.x.x 1For the Windows 8 Preview I simply adapted this:
netsh interface ipv4 add dnsserver "local area connection" x.x.x.x 2
netsh interface ipv4 add dnsserver "Wired Ethernet Connection" x.x.x.x 1Being an embracer of PowerShell and all the 2000+ new cmdlets in Windows Server I decided to figure out how to do this the PowerShell way.
netsh interface ipv4 add dnsserver "Wired Ethernet Connection" x.x.x.x 2
*Note the change to the interface name
Well, I have to say it took a while just to find the right cmdlets because I began at IPAddress or IPAdapter. Not thinking that there would be a DnsClientServerAddress.
Get-DnsClientServerAddressNow, to set, just turn this around to the Set-
Set-DnsClientServerAddress -InterfaceAlias vEthernet* -ServerAddresses "x.x.x.x","x.x.x.x"Note how I feed in the multiple addresses, as list of individual comma separated strings.
Then, there is the one-liner (I discuss finding the proper NetAdapter is other posts).
Get-NetAdapter | Set-DnsClientServerAddress -ServerAddresses "x.x.x.x","x.x.x.x"