Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help writing error check and log on a script

Status
Not open for further replies.

sktala

MIS
Jan 2, 2007
12
US
Sorry, here is the script.


Set objOU = GetObject("LDAP://OU=GP Test,OU=OIRM,DC=kc,DC=kingcounty,DC=lcl")
objOU.Filter = Array("Computer")

On Error Resume Next
For Each objComputer In objOU
' WScript.Echo objcomputer.CN
strComputer = objComputer.CN

Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False

arrDNSServers = Array ("146.129.177.130", "146.129.56.6") 'change to new DNS servers IP)

strPrimaryServer = "146.129.177.130" 'change to new primary WIN server IP
strSecondaryServer = "146.129.56.6" 'change to new secondary WIN server IP

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard In colNetCards
'Modify DNS Server search order
objNetCard.SetDNSServerSearchOrder(arrDNSServers)

'Assign DNS Domain
WScript.Echo objNetCard.SetDNSDomain("kc.kingcounty.lcl")

'Modify Dynamic DNS RegistrationobjNetCard.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, _
DOMAIN_DNS_REGISTRATION

'Assign WINS Server
objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer

'Modify the DNS Suffix Search
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
arrDNSSuffixes = Array("kc.kingcounty.lcl", "kingcounty.lcl", "dot.kingcounty.lcl")
'change to your own order
objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)

Next
Next
 
Do a search for FileSystemObject and you will find several examples of writing to a text file for logging purposes.

Look at the methods you are using since they may return error codes you can also use to log whether they were successful or not.

I would also suggest you add a ping function to see if the computer is reachable before trying to do anything to it. Look in the FAQ section for examples on that.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top