Jump to content

Excel DNS-Adressen


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Recommended Posts

Posted

Hallo zusammen,

ich habe ein kleines Problem und würde das gerne mal posten eventuell kennt jemand dazu ja eine Lösung.

Ich möchte gerne alle DNS-Adressen eines Systems auslesen und in folgenden Format in eine Excel Zelle

eintragen.

192.168.0.1; 192.168.0.2; 192.168.0.3

Ich würde mich echt freuen wenn jemand dazu ein Lösung hat

 

Gruß

Tom

 

strComputer = "."
DIM intRow
SET objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add

SET objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
SET IPConfigSet = objWMIService.ExecQuery _
   ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
intRow = 2 

objExcel.Visible = True

objExcel.Range("A:A").ColumnWidth = 10
objExcel.Cells(1, 1).Value = "DNS-Address"
FOR EACH IPConfig IN IPConfigSet
   IF NOT IsNull(IPConfig.DNSServerSearchOrder) THEN
 FOR i = 0 TO UBound(IPConfig.DNSServerSearchOrder)
  objExcel.Cells(intRow, 1).Value = IPConfig.DNSServerSearchOrder(i)
 'wscript.echo IPConfig.DNSServerSearchOrder(i)  
 NEXT
END IF
NEXT

Posted

Hab da noch was in meiner Skript-Sammlung gefunden. Das Skript war mal für mehr als einen Rechner gedacht, darum auch das Array und die Extra-Schleife außen rum.

 

set WshShell = WScript.CreateObject("WScript.Shell")

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.Workbooks.Add

dim strComputers, row
strComputers = Array(".")
row = 1

For Each computer in strComputers
Set objWMIService = GetObject("winmgmts:\\" & computer & "\root\CIMV2") 

objExcel.Cells(row, 1).Value = computer
objExcel.Cells(row, 1).Font.Underline = True

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE",,48) 
For Each objItem in colItems
	If not isNull(objItem.DNSServerSearchOrder) Then
		row = row + 1
		objExcel.Cells(row, 1).Value = Right(objItem.Caption, (Len(objItem.Caption) - 11))
		objExcel.Cells(row, 2).Value = Join(objItem.DNSServerSearchOrder, "; ")
	End If
Next

row = row + 2
Set objWMIService = Nothing
Next

objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.SaveAs(WshShell.ExpandEnvironmentStrings("%userprofile%") & "\Desktop\" & "DNSServer.xls")
objExcel.DisplayAlerts = True
objExcel.Quit()

Set objExcel = Nothing
Set WshShell = Nothing

Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...