desktoprat
MIS
Hey guys, its been a few years since I've been around, but I am trying another round of teaching myself more about scripting. So, here goes.....
The following script works with the exception of the line that says
objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)
The error being returned is invalid method. I am looking at the TechNet listing for the method and I am pretty sure I am using the proper procedures in using it.
So, can you see what I'm not doing correctly???
Thank you,
Desktoprat
p.s. the values in the arrays have been changed to ensure I don't get any potential nasty notes from other people in my organization, whoever they may be.
'=========================================================
Option Explicit
Dim strComputer, strPrimaryServer, strSecondaryServer
Dim objWMIService, colNetAdapters, objNetAdapter
Dim errEnable, arrDNSServers, arrDNSSuffixes
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
arrDNSServers = Array("1.2.3.4","1.2.3.5","1.2.3.6","1.2.3.7","1.2.3.8")
objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
arrDNSSuffixes = Array("abc.net", "abc.edu")
objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)
strPrimaryServer = "1.2.3.4"
strSecondaryServer = "1.2.3.5"
objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer
Next
MsgBox "NIC has been configured
The following script works with the exception of the line that says
objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)
The error being returned is invalid method. I am looking at the TechNet listing for the method and I am pretty sure I am using the proper procedures in using it.
So, can you see what I'm not doing correctly???
Thank you,
Desktoprat
p.s. the values in the arrays have been changed to ensure I don't get any potential nasty notes from other people in my organization, whoever they may be.
'=========================================================
Option Explicit
Dim strComputer, strPrimaryServer, strSecondaryServer
Dim objWMIService, colNetAdapters, objNetAdapter
Dim errEnable, arrDNSServers, arrDNSSuffixes
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
arrDNSServers = Array("1.2.3.4","1.2.3.5","1.2.3.6","1.2.3.7","1.2.3.8")
objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
arrDNSSuffixes = Array("abc.net", "abc.edu")
objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)
strPrimaryServer = "1.2.3.4"
strSecondaryServer = "1.2.3.5"
objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer
Next
MsgBox "NIC has been configured