locked
VB Script RRS feed

  • Question

  • Hi Champs,

    Please help me find a script which gives me what the primary and secondary DC/DNS/WINS server is of all the Exchange 2003 servers in a domain.

    Thanks in advance.

    any body has a script on this please.
    Monday, March 8, 2010 3:49 AM

Answers

  • Hi Shiva,

     

    You can use the following Script. You need to create a xls file containing all your exchange servers and save it in C: drive, named as exchangeserverlist.xls. (First columnm starting from second row should have all your exchange servers. This script should give you in the xls file, WINS and DNS/DC configuration of all network cards in your servers (it should not be dhcp enabled)

    On Error Resume Next

    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open _
        ("C:\ExchangeServerList.xls")
    Set objWorksheet = objWorkbook.Worksheets(1)

    objWorksheet.Activate

    objExcel.Visible = True

    intRow = 2
    intRow1 = 2

    Do Until objExcel.Cells(intRow,1).Value = ""
     strComputer = objExcel.Cells(intRow, 1).Value
     wscript.echo strComputer
     objExcel.Cells(intRow1, 2).Value = strComputer
     err.clear
     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     if err.number <> 0 then
      objExcel.Cells(intRow1, 3).Value = "error connecting to WMI"
      intRow1 = intRow1 + 1
     else
      Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter where AdapterType = 'Ethernet 802.3'")
       For Each objItem in colItems
           strMac = objItem.MAcAddress
       intIndex = objItem.Index
       wscript.echo strMac
       Set colNetAdapters = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where index = '" & intIndex & "' and IPEnabled = true and dhcpenabled = false")
       For Each objNetAdapter in colNetAdapters
        wscript.echo objNetAdapter.macaddress
        objExcel.Cells(intRow1, 2).Value = strComputer
        objExcel.Cells(intRow1, 3).Value = objNetAdapter.Index & ". " & objNetAdapter.Description
        objExcel.Cells(intRow1, 4).Value = objNetAdapter.IPAddress
        objExcel.Cells(intRow1, 5).Value = objNetAdapter.WINSPrimaryServer
        objExcel.Cells(intRow1, 6).Value = objNetAdapter.WINSSecondaryServer
        arrDNS = objNetAdapter.DNSServerSearchOrder
        intCol = 7
        for each DNSaddr in arrDNS
         objExcel.Cells(intRow1, intCol).Value = DNSaddr
         intCol = intCol + 1
        next
        intRow1 = intRow1 + 1
       Next
      Next
     end if
     intRow = intRow + 1
     
    Loop

     

    Regards

    Jas


    Jaswinder Singh
    • Proposed as answer by SinghJas Wednesday, March 31, 2010 3:17 PM
    • Marked as answer by Andrew Barnes Saturday, April 24, 2010 11:32 AM
    Wednesday, March 31, 2010 3:17 PM

All replies

  • Hi Shiva,

     

    You can use the following Script. You need to create a xls file containing all your exchange servers and save it in C: drive, named as exchangeserverlist.xls. (First columnm starting from second row should have all your exchange servers. This script should give you in the xls file, WINS and DNS/DC configuration of all network cards in your servers (it should not be dhcp enabled)

    On Error Resume Next

    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open _
        ("C:\ExchangeServerList.xls")
    Set objWorksheet = objWorkbook.Worksheets(1)

    objWorksheet.Activate

    objExcel.Visible = True

    intRow = 2
    intRow1 = 2

    Do Until objExcel.Cells(intRow,1).Value = ""
     strComputer = objExcel.Cells(intRow, 1).Value
     wscript.echo strComputer
     objExcel.Cells(intRow1, 2).Value = strComputer
     err.clear
     Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     if err.number <> 0 then
      objExcel.Cells(intRow1, 3).Value = "error connecting to WMI"
      intRow1 = intRow1 + 1
     else
      Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter where AdapterType = 'Ethernet 802.3'")
       For Each objItem in colItems
           strMac = objItem.MAcAddress
       intIndex = objItem.Index
       wscript.echo strMac
       Set colNetAdapters = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where index = '" & intIndex & "' and IPEnabled = true and dhcpenabled = false")
       For Each objNetAdapter in colNetAdapters
        wscript.echo objNetAdapter.macaddress
        objExcel.Cells(intRow1, 2).Value = strComputer
        objExcel.Cells(intRow1, 3).Value = objNetAdapter.Index & ". " & objNetAdapter.Description
        objExcel.Cells(intRow1, 4).Value = objNetAdapter.IPAddress
        objExcel.Cells(intRow1, 5).Value = objNetAdapter.WINSPrimaryServer
        objExcel.Cells(intRow1, 6).Value = objNetAdapter.WINSSecondaryServer
        arrDNS = objNetAdapter.DNSServerSearchOrder
        intCol = 7
        for each DNSaddr in arrDNS
         objExcel.Cells(intRow1, intCol).Value = DNSaddr
         intCol = intCol + 1
        next
        intRow1 = intRow1 + 1
       Next
      Next
     end if
     intRow = intRow + 1
     
    Loop

     

    Regards

    Jas


    Jaswinder Singh
    • Proposed as answer by SinghJas Wednesday, March 31, 2010 3:17 PM
    • Marked as answer by Andrew Barnes Saturday, April 24, 2010 11:32 AM
    Wednesday, March 31, 2010 3:17 PM
  • Hi Jas,

     

    Thanks a lot for your efforts on this. Much Appreciated.

    Could it be possible to add one more column in the xls file generated which mentions the DC name to which the exchange server logs in.

    Thanks & Regards

     

    Shivakumar

    Thursday, April 1, 2010 7:11 AM