Here is his mail with a link to the module:
--BEGIN--
“Hi Jimmy,
I finally got time to finish the blog-post:
http://blog.powershell.no/2011/11/22/introducing-the-powershell-network-adapter-configuration-module
Rather than creating a single script for the specific task I ended up creating a function in PowerShell, including capabilities such as error handling, logging and the option to either replace or add/remove entries from the DNSSearchOrder-list.
I also ended up creating a module I published on Codeplex, since I couldn`t find any complete library for managing network adapters from PowerShell (or other languages for that matter).
So let`s hope people in the community will contribute with more commands to the module… J (Win 8 will provide native modules for things like this, but I guess they won`t be backward compatible)”
--END--
And here is the Script:
--BEGIN--
I couldn`t resist re-writing your script into PowerShell ;)
It does reset the DNSServerSearchOrder rather than replacing specified IPs, so it`s not exactly the same.
# NAME:Set-DNSServer.ps1
## AUTHOR: Jan Egil Ring
# EMAIL: [JImmy removed this]
#
# VERSION HISTORY:
# 1.0 06.10.2011 - Initial release
#Custom variables
$FilePath = "C:\serverNames.txt"$DNSServerSearchOrder = "10.230.20.9","10.230.20.10"
if (Test-Connection -ComputerName $computer -Count 1 -Quiet) {
$NICs = Get-WmiObject -Query "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE AND DHCPEnabled = FALSE" -Computer $computer
if ($NICs) {
foreach ($NIC in $NICs) {
if ($NIC.DNSServerSearchorder) {
$NIC.SetDNSServerSearchOrder($DNSServerSearchOrder)
}
}
}
}
else {Write-Host "Unable to contact $computer"
}
}
--END--