itomix 10 Posted June 12, 2009 Report Posted June 12, 2009 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 Quote
ZeroKnowledge 11 Posted June 12, 2009 Report Posted June 12, 2009 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 Quote
itomix 10 Posted June 12, 2009 Author Report Posted June 12, 2009 Dankeschön ;o) ich werde es gleich mal ausprobieren ;o) Gruß Tom Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.