As promised. IP addresses have been changed to protect the innocent. The script relies on a text file with server names. I'm sure there will be questions as to why it was written the way it was so I'll do my best to answer those as they come up.
======================================================== Option Explicit 'On Error Resume Next 'Variable Declarations Dim arrNewDNSServers,objWMIService,colNetCards,objNetCard,arrCurrentDNS,strWINSOne,strWINSTwo,strMACAdd Dim objFSO,objFileList,strLine,i,strWINSPrime,strWINSSec,strDNSPrime,strDNSSec strWINSPrime="10.10.10.10" strWINSSec="10.10.10.11" strDNSPrime="10.10.10.12" strDNSSec="10.10.10.13" Set objFSO=CreateObject("Scripting.FileSystemObject") 'Create the FileSystemObject for accessing the filesystem on the local pc Set objFileList=objFSO.OpenTextFile("c:\Scripts\NICSettings\ServerList.txt",1) 'Open the list file ErrorTrap "NULL","NULL",err.Number,err.Description,"Opening List File" arrNewDNSServers = Array(strDNSPrime,strDNSSec) 'Array containing new DNS information 'Loop through the list file. Do Until objFileList.AtEndOfStream strLine = objFileList.ReadLine 'Read a line from the list file ErrorTrap strLine,"NULL",err.Number,err.Description,"Reading List File" Set objWMIService = GetObject("winmgmts:\\"&strLine&"\root\CIMV2")'Connect to the remote WMI ErrorTrap strLine,"NULL",err.Number,err.Description,"Setting objWMIService" Set colNetCards=objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration")'Query the remote network adapters ErrorTrap strLine,"NULL",err.Number,err.Description,"Loading Network Cards" For Each objNetCard in colNetCards 'Loop through each network adapter strMACAdd=objNetCard.MACAddress 'Load the remote MAC to a variable ErrorTrap strLine,"NULL",err.Number,err.Description,"Loading MAC Address into variable" arrCurrentDNS=objNetCard.DNSServerSearchOrder 'Load current DNS into a variable ErrorTrap strLine,strMACAdd,err.Number,err.Description,"Loading DNS settings into an array" strWINSOne=objNetCard.WINSPrimaryServer 'Load primary WINS server into a variable ErrorTrap strLine,strMACAdd,err.Number,err.Description,"Loading primary WINS server into variable" strWINSTwo=objNetCard.WINSSecondaryServer 'Load secondary WINS server into a variable ErrorTrap strLine,strMACAdd,err.Number,err.Description,"Loading secondary WINS server into variable" If objNetCard.DHCPEnabled=False Then 'Check if DHCP is enabled. If not, proceed. If Not IsNull(arrCurrentDNS) Then 'Check if there are currently any DNS settings For i = 0 to UBound(arrCurrentDNS) 'Cycle through DNS servers If (arrCurrentDNS(i)="20.20.20.20") Then 'Look for old DNS info, if found, proceed. objNetCard.SetDNSServerSearchOrder(arrNewDNSServers)'Set new DNS info ErrorTrap strLine,strMACAdd,err.Number,err.Description,"Setting New DNS Settings" 'Exit For End If Next End If If strWINSONE="20.20.20.20" or strWINSOne = "20.20.20.21" Then 'Check for old WINS info. If found, proceed. objNetCard.SetWINSServer strWINSPrime,strWINSSec ' Set new WINS info ErrorTrap strLine,strMACAdd,err.Number,err.Description,"Setting new WINS settings" End If End If 'MsgBox(strMACAdd&","&strWINSOne&","&strWINSTwo&","&strDNSSettings) Next Loop MsgBox("done") ' This is the error trapping subroutine. It is called after any code is executed with the exception of setting variables Sub ErrorTrap(strWSName,strMACInfo,errNum,errDesc,strComments) Dim objLogFile If Not objFSO.FileExists("C:\scripts\NICSettings\LogFile.txt") Then 'Check for the existence of a log file objFSO.CreateTextFile("C:\scripts\NICSettings\LogFile.txt") 'Create one if there is none End If Set objLogFile = objFSO.OpenTextFile("C:\scripts\NICSettings\LogFile.txt",8) 'Open the logfile for appending objLogFile.WriteLine(Date&" "&Time&": "&strWSName&":"&strMACInfo&" - "&strComments&", Error Number:"&errNum&", Error Description: "&errDesc) 'Write error info err.Clear 'Clear the error number and allow script to continue objLogFile.Close 'Close the logfile End Sub ======================================================== On Wed, May 19, 2010 at 10:35 AM, Micheal Espinola Jr < michealespin...@gmail.com> wrote: > <hic!> thso fwaht?! > > -- > ME2 > > > On Tue, May 18, 2010 at 5:03 PM, Jonathan Link > <jonathan.l...@gmail.com>wrote: > >> Script lush! >> >> >> On Tue, May 18, 2010 at 7:21 PM, Micheal Espinola Jr < >> michealespin...@gmail.com> wrote: >> >>> Its always welcomed to share useful scripts! >>> >>> -- >>> ME2 >>> >>> >>> >>> On Tue, May 18, 2010 at 3:29 PM, Sean Martin <seanmarti...@gmail.com>wrote: >>> >>>> First, thanks for all of the feedback. Some interesting opinions out >>>> there. I've always been open to change so it's good to hear all of the >>>> positives/negatives regarding which route to take. It sounds like DHCP >>>> would >>>> be the way to go with the majority of our servers, excluding the >>>> infrastructure servers. >>>> >>>> With that said, it's probably a change that will occur through attrition >>>> rather than changing our current method all at once. The main reason for >>>> that is our network services department wants us to change the subnets our >>>> servers currently reside on to further segment stuff. We've got way too >>>> much >>>> work on our plates to investigate changing the addresses on all of our >>>> servers so that will already be a slow transition. >>>> >>>> In the meantime, a co-worker and I put together what we hope is a >>>> functional VB script that will make the necessary changes to the existing >>>> WINs and DNS settings. If anyone's interested in seeing it (and maybe >>>> reviewing it for validity), I'd be happy to pass it along. >>>> >>>> - Sean >>>> >>>> On Tue, May 18, 2010 at 1:41 PM, Ben Scott <mailvor...@gmail.com>wrote: >>>> >>>>> On Tue, May 18, 2010 at 4:24 PM, Sean Martin <seanmarti...@gmail.com> >>>>> wrote: >>>>> > What are some of the pros/cons of using DHCP for servers...? >>>>> >>>>> For an environment like you describe, with hundreds of servers, I >>>>> would recommend DHCP for all but critical network infrastructure >>>>> servers. I'd use manual configuration for anything serving DHCP, DNS, >>>>> WINS, or Active Directory. Everything else, DHCP, with reservations. >>>>> >>>>> Just to be clear: DHCP does not have to mean a dynamic IP address. >>>>> You can statically assign an IP address via a DHCP reservation. And >>>>> there are tools to help you do things like automatically provision the >>>>> reservations, based on name or MAC address or whatever. >>>>> >>>>> > I've heard mention of not using DHCP to prevent DHCP broadcasts >>>>> > but with a properly designed lease interval, I can't imagine the DHCP >>>>> > traffic being that much of burden on today's networks.... >>>>> >>>>> As ME2 says, it really depends on the environment, but I would >>>>> generally agree. You'll already be needing infrastructure to support >>>>> DNS, prolly Active Directory, possibly WINS, Window Updates, etc., >>>>> etc. If DHCP is going to push you over the edge you're already way >>>>> too close to the edge. :) >>>>> >>>>> The one thing you *may* notice is a surge in broadcast traffic after >>>>> rebooting or starting a large group of servers -- say, after a >>>>> software update, or a long power outage. In general, though, you're >>>>> already going to be seeing that due to ARP and maybe NetBIOS >>>>> registration. So again, if this is a problem you're likely already >>>>> experiencing it. The usual solution is to stagger reboot/startup. >>>>> >>>>> -- Ben >>>>> >>>>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ >>>>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ >>>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> >> >> >> > > > > > ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~