I recently received a question from James via email (thanks for sending it - readers, you can send questions to me, too. My email domain is ConcentratedTech.com, and my email alias is powershell, and you can probably figure out the address from that). In a very concise email (thanks again!) he asked:
Cool. I immediately thought of the Win32_NetworkAdapterConfiguration WMI class. Now, the trick with this class is figuring out how to query just actual Ethernet adapters and not all the fake virtual adapters in Windows. I do it this way:
That'll obviously differ in your environment, but hopefully you get the idea. From there, you can execute some methods of that class. There's a SetWINSServer method (ugh, WINS - sigh), a SetDNSDomain method, a SetDNSSuffixSearchOrder method, and so on. I don't see "DNS Connection," although I'm not sure what you're looking for on that setting, James. With the right method - and the docs page at http://msdn.microsoft.com/en-us/library/aa394217(v=vs.85).aspx - you're on the right track. You could implement this as a logon script or something, or just target computers remotely:
That'll get you a lot of what you need. It gets a bit tricky passing in arrays (which is what SetDNSServerSearchOrder requires, for example), but there are plenty of examples out there. Now, the one thing you won't get is the enabling of LMHOSTS, which isn't an adapter setting but is an operating system setting buried in the registry. http://www.pctools.com/guides/registry/detail/1285 has some good details on which key to use, and you can use the registry drives (HKLM:) in PowerShell to access those settings. This is a perfect time to look into Invoke-Command and PowerShell v2 remoting (assuming you've deployed, or can deploy, PowerShell v2 to your target machines), since it'll let you manipulate the registry on the remote machines very easily.
All that said, when it comes to client computers at least, I'm accustomed to just using DHCP to push out those values. You can do DNS servers, domain name, WINS servers, and lots more. That's a big reason I usually put my servers on DHCP reservations, in fact - so that I can change these options via DHCP without a lot of hassle, but still have the servers getting the same address.
Hope that helps a bit! Anyone else been in this situation? How have you handled it?