Need assistance on below script RRS feed

  • Question

  • Hi,

    I have a script to set preferred and alternate DNS server in multiple remote servers,  can anyone help me to add a success / failure logging facility (with hostname / IP address) in the below script.

    On Error Resume Next

    Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
    Dim objShell : Set objShell = CreateObject("Wscrfipt.Shell")
    Dim objFile : Set objFile = objFSO.OpenTextFile("c:\Computers.txt") 
    counter = 1
    Do While Not objFile.AtEndOfStream
    currentserver = objFile.ReadLine
    Set objWMIService = GetObject("winmgmts:"  & "{impersonationLevel=impersonate}!\\" & currentserver & "\root\cimv2")
    Set colNicConfigs = objWMIService.ExecQuery  ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    For Each objNicConfig In colNicConfigs
    If Not IsNull(objNicConfig.DNSServerSearchOrder) Then
               arrDNSServers = Array("", "", "")
    End If



    • Moved by Bill_Stewart Friday, August 14, 2015 7:35 PM This is not "scripts on demand"
    Friday, July 10, 2015 8:31 AM

All replies

  • To log results you need to capture the return code of the operation.  YOU may also need to add error control into your script.  Start by studying how to use file output and error control here: https://technet.microsoft.com/en-us/scriptcenter/dd772284

    To check results use the return code: https://msdn.microsoft.com/en-us/library/aa393295(v=vs.85).aspx

    We will not rewrite yor script for you.  Either ask the original author to modify the script or contact a consultant to help.  This froum is for technicians who use scripting in their work.  If you choose to learn script we will help with specific questions but not "please redesign my script that I found".

    If you choose to learn to script then start by removing the "On Error Resume Next" statement and fix and report all errors.


    • Edited by jrv Friday, July 10, 2015 12:23 PM
    Friday, July 10, 2015 12:23 PM