Re: Change DNS ip configuration through script

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



that was really excellent. but with a bit of difference I wanted to change Ip
address of 10000 servers which list is their with me in excel.

and also wanted to access the error that which servers i was not able to
access


"Steve Schofield" wrote:

> Here is a script I used to set my DNS primary and alternate on machines.
> Works on w2k and w2k3 servers.
>
> Call Main()
> wscript.echo "Done"
>
> ' ---------------------------------------------------------------------------------------
> ' | Main Sub |
> ' ---------------------------------------------------------------------------------------
>
> Sub Main()
> SetDNSServerSearchOrder()
> End Sub
>
>
> ' ---------------------------------------------------------------------------------------
> ' | Change DNS Server Search order |
> ' ---------------------------------------------------------------------------------------
>
> Sub SetDNSServerSearchOrder()
> ' On Error Resume Next
> Err.clear
>
> dim aDNS(1)
>
> aDNS(0) = "CHANGEMEPrimaryIPAddress"
> aDNS(1) = "CHANGEMEAlternateIPAddress"
>
> 'Set Networking Managing Objects
> strComputer = "."
> set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colItems = objWMIService.ExecQuery("Select * From
> Win32_NetworkAdapterConfiguration Where IPEnabled = 1")
>
> For Each objItem in colItems
> errDNS = objItem.SetDNSServerSearchOrder()
> wscript.sleep 500
> errDNS = objItem.SetDNSServerSearchOrder(aDNS)
> Next
>
> set objWMIService = Nothing
> set colItems = Nothing
>
> If err.number <> 0 Then
> dim snum, sdesc
> snum = err.number
> sdesc = err.description
> ErrorHandler snum, sdesc
> End If
> End Sub
>
>
> ' ---------------------------------------------------------------------------------------
> ' | Error Handler |
> ' ---------------------------------------------------------------------------------------
>
> Sub ErrorHandler(byVal errorNum, byVal errorDesc)
> ' On Error Resume Next
> Err.Clear
>
> theDesc = "Error Number: " & errornum & " Error Description: " &
> errorDesc
> WshShell.LogEvent 1, theDesc
> dim objFile, fso2
> objFile = "InstallErr.txt"
> If fso.FileExists(objFile) Then
> Set objFile = fso.OpenTextFile(objFile, 8)
> objFile.WriteLine " -Error Number:" & errorNum & " Error Desc:" &
> errorDesc
> Else
> Set objFile = fso.CreateTextFile(objFile, True)
> objFile.WriteLine " -Error Number:" & errorNum & " Error Desc:" &
> errorDesc
> End If
> objFile.close
> Err.clear
> End Sub
>
> Steve Schofield
> Microsoft MVP - ASP/ASP.NET
> ASPInsider Member - MCP
>
> http://www.orcsweb.com/
> Managed Complex Hosting
> #1 in Service and Support
>
> "tejdeep_s@xxxxxxxxxxx" <tejdeep_s@xxxxxxxxxxx@discussions.microsoft.com>
> wrote in message news:60A57D19-63F9-4DCB-B939-3584D7D89B78@xxxxxxxxxxxxxxxx
> > can anyone suggest how to
> >
> > Change DNS ip configuration through script
>
>
>
.



Relevant Pages

  • Re: Change DNS ip configuration through script
    ... Sub Main ... Sub SetDNSServerSearchOrder() ... Sub ErrorHandler(byVal errorNum, byVal errorDesc) ... Set objFile = fso.CreateTextFile ...
    (microsoft.public.scripting.wsh)
  • Re: Home Directories not mapping
    ... Secure channel for domain 'DOMAIN' was successfully set to PDC ... >> looking at those servers to see what state they are in. ... >>> For Each objGroup In ObjGroupDict ... >>> Sub InformationSystems ...
    (microsoft.public.win2000.active_directory)
  • Re: Re-configuring remoting from config file during application session
    ... two different servers remoting the same object type, ... > Private Sub frmMain_Load(ByVal sender As Object, ... >> channel and formatter info is in the config file. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Symrefs
    ... i know reasons why you do that such as a personal list of ... actual sub names or even map 1 to many so a dispatch ... I write web application for collecting weather data for as many locations as possible. ... On some servers you can collect data about tens or hundred towns, on some servers you can get data about one location only. ...
    (comp.lang.perl.misc)
  • Re: Home Directories not mapping
    ... We have used the SET command to identify the logonserver for one user ... > looking at those servers to see what state they are in. ... >> For Each objGroup In ObjGroupDict ... >> Sub InformationSystems ...
    (microsoft.public.win2000.active_directory)