UEZ Posted December 3, 2007 Posted December 3, 2007 (edited) Hi,I looked for a solution in the forum but didn't find anything about how to get more information e.g. DNS search order.I can get information in VBS (extract from Scriptomatic):Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ &h30)... strDNSServerSearchOrder = Join(objItem.DNSServerSearchOrder, ",") WScript.Echo "DNSServerSearchOrder: " & strDNSServerSearchOrder...AU3 (extract from Scriptomatic):$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ 0x30)... $strDNSDomainSuffixSearchOrder = $objItem.DNSDomainSuffixSearchOrder(0) $Output = $Output & "DNSDomainSuffixSearchOrder: " & $strDNSDomainSuffixSearchOrder & @CRLF...In VBS each item in objItem.DNSServerSearchOrder will be joined (comma seperated) but in AU3 only the first item will be saved.Is it possible to get also multiple items as in the example above? I'm writting a script for collecting several network information in au3 but couldn't find a solution to get more than one IP address, DNS search order, etc.THANKS for help,UEZ Edited November 8, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
PsaltyDS Posted December 3, 2007 Posted December 3, 2007 Like this: $Output = "DNSDomainSuffixSearchOrder: " & @CRLF For $objItem In $colItems $strDNSDomainSuffixSearchOrder = $objItem.DNSDomainSuffixSearchOrder(0) $Output &= $strDNSDomainSuffixSearchOrder & @CRLF Next MsgBox(64, "Output", $Output) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
UEZ Posted December 3, 2007 Author Posted December 3, 2007 (edited) That's not what I'm looking for because if you have several DNS search orders entered for only one network connection then your script willl return only one item not all items from one network connection. This will only return the first DNS Search Order for all network connections (in VBS you will get all DNS entries for each network connection -> Join function) In companies normally you have several DNS servers and with VBS script you will get all DNS entries for one network connection. But anyway, thanks for the quick response: Here the quick full code for getting the 1st entryy of the DNS of each network card: $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = @ComputerName $Output="" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=True", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $Output = "DNSServerSearchOrder: " & @CRLF For $objItem In $colItems $strDNSDomainSuffixSearchOrder = $objItem.DNSServerSearchOrder(0) $Output &= $strDNSDomainSuffixSearchOrder & @CRLF Next MsgBox(64, "Output", $Output) Edited December 3, 2007 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ptrex Posted December 4, 2007 Posted December 4, 2007 @UEZ Maybe this can get you started : expandcollapse popup#include <date.au3> Dim $strComputer = "." Dim $objWMIService, $colAdapters, $n Dim $utcLeaseObtained, $utcLeaseObtained, $utcLeaseExpired, $strLeaseObtained, $utcLeaseExpires, $strLeaseExpires $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colAdapters = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") $n = 1 For $objAdapter in $colAdapters ConsoleWrite ("Network Adapter " & $n & @CR) ConsoleWrite ("================="& @CR) ConsoleWrite (" Description: " & $objAdapter.Description& @CR) ConsoleWrite (" Physical (MAC) address: " & $objAdapter.MACAddress& @CR) ConsoleWrite (" Host name: " & $objAdapter.DNSHostName& @CR) If Not ($objAdapter.IPAddress) = " " Then For $i = 0 To UBound($objAdapter.IPAddress) ConsoleWrite (" IP address: " & $objAdapter.IPAddress($i)& @CR) Next EndIf If Not ($objAdapter.IPSubnet) = " " Then For $i = 0 To UBound($objAdapter.IPSubnet) ConsoleWrite (" Subnet: " & $objAdapter.IPSubnet($i)& @CR) Next EndIf If Not ($objAdapter.DefaultIPGateway) = " " Then For $i = 0 To UBound($objAdapter.DefaultIPGateway) ConsoleWrite (" Default gateway: " & _ $objAdapter.DefaultIPGateway($i)& @CR) Next EndIf ConsoleWrite (" DNS"& @CR) ConsoleWrite (" ---"& @CR) ConsoleWrite (" DNS servers in search order:"& @CR) If Not ($objAdapter.DNSServerSearchOrder) = " " Then For $i = 0 To UBound($objAdapter.DNSServerSearchOrder) ConsoleWrite (" " & $objAdapter.DNSServerSearchOrder($i)& @CR) Next EndIf ConsoleWrite (" DNS domain: " & $objAdapter.DNSDomain& @CR) If Not ($objAdapter.DNSDomainSuffixSearchOrder) = " " Then For $i = 0 To UBound($objAdapter.DNSDomainSuffixSearchOrder) ConsoleWrite (" DNS suffix search list: " & _ $objAdapter.DNSDomainSuffixSearchOrder($i)& @CR) Next EndIf ConsoleWrite (" DHCP"& @CR) ConsoleWrite (" ----"& @CR) ConsoleWrite (" DHCP enabled: " & $objAdapter.DHCPEnabled& @CR) ConsoleWrite (" DHCP server: " & $objAdapter.DHCPServer& @CR) If Not ($objAdapter.DHCPLeaseObtained) = " " Then $utcLeaseObtained = $objAdapter.DHCPLeaseObtained $strLeaseObtained = WMIDateStringToDate($utcLeaseObtained) Else $strLeaseObtained = "" EndIf ConsoleWrite (" DHCP lease obtained: " & $strLeaseObtained& @CR) If Not ($objAdapter.DHCPLeaseExpires) = " " Then $utcLeaseExpires = $objAdapter.DHCPLeaseExpires $strLeaseExpires = WMIDateStringToDate($utcLeaseExpires) Else $strLeaseExpires = "" EndIf ConsoleWrite (" DHCP lease expires: " & $strLeaseExpires& @CR) ConsoleWrite (" WINS"& @CR) ConsoleWrite (" ----"& @CR) ConsoleWrite (" Primary WINS server: " & $objAdapter.WINSPrimaryServer& @CR) ConsoleWrite (" Secondary WINS server: " & $objAdapter.WINSSecondaryServer& @CR) ConsoleWrite(@CR) $n = $n + 1 Next Func WMIDateStringToDate($utcDate) Local $Return $Return = (StringMid($utcDate, 5, 2) & "/" & _ StringMid($utcDate, 7, 2) & "/" & _ StringLeft($utcDate, 4) & " " & _ StringMid ($utcDate, 9, 2) & ":" & _ StringMid($utcDate, 11, 2) & ":" & _ StringMid($utcDate, 13, 2)) Return $Return EndFunc Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
PsaltyDS Posted December 4, 2007 Posted December 4, 2007 (edited) I think you are confusing DNSDomainSuffixSearchOrder with DNSServerSearchOrder. Also, you only get the first entry because you specify and index with (0). If you leave that off, you get an array that you can walk with a For/Next loop. This is a translation of an MS Scripting Guys script that shows both: expandcollapse popup$strComputer = "." $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $colAdapters = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") $n = 1 $sMsg = "" For $objAdapter In $colAdapters $sMsg &= "Network Adapter " & $n & @CRLF $sMsg &= "=================" & @CRLF $sMsg &= " Description: " & $objAdapter.Description & @CRLF $sMsg &= " Physical (MAC) address: " & $objAdapter.MACAddress & @CRLF $sMsg &= " Host name: " & $objAdapter.DNSHostName & @CRLF If $objAdapter.IPAddress <> "" Then For $i = 0 To UBound($objAdapter.IPAddress) - 1 $sMsg &= " IP address: " & $objAdapter.IPAddress($i) & @CRLF Next EndIf If $objAdapter.IPSubnet <> "" Then For $i = 0 To UBound($objAdapter.IPSubnet) - 1 $sMsg &= " Subnet: " & $objAdapter.IPSubnet($i) & @CRLF Next EndIf If $objAdapter.DefaultIPGateway <> "" Then For $i = 0 To UBound($objAdapter.DefaultIPGateway) - 1 $sMsg &= " Default gateway: " & $objAdapter.DefaultIPGateway($i) & @CRLF Next EndIf $sMsg &= @CRLF $sMsg &= " DNS" & @CRLF $sMsg &= " ---" & @CRLF $sMsg &= " DNS servers in search order:" & @CRLF If $objAdapter.DNSServerSearchOrder <> "" Then For $i = 0 To UBound($objAdapter.DNSServerSearchOrder) - 1 $sMsg &= " " & $objAdapter.DNSServerSearchOrder($i) & @CRLF Next EndIf $sMsg &= " DNS domain: " & $objAdapter.DNSDomain & @CRLF If $objAdapter.DNSDomainSuffixSearchOrder <> "" Then For $i = 0 To UBound($objAdapter.DNSDomainSuffixSearchOrder) - 1 $sMsg &= " DNS suffix search list: " & $objAdapter.DNSDomainSuffixSearchOrder($i) & @CRLF Next EndIf $sMsg &= @CRLF $sMsg &= " DHCP" & @CRLF $sMsg &= " ----" & @CRLF $sMsg &= " DHCP enabled: " & $objAdapter.DHCPEnabled & @CRLF $sMsg &= " DHCP server: " & $objAdapter.DHCPServer & @CRLF If $objAdapter.DHCPLeaseObtained <> "" Then $utcLeaseObtained = $objAdapter.DHCPLeaseObtained $strLeaseObtained = WMIDateStringToDate($utcLeaseObtained) Else $strLeaseObtained = "" EndIf $sMsg &= " DHCP lease obtained: " & $strLeaseObtained & @CRLF If $objAdapter.DHCPLeaseExpires <> "" Then $utcLeaseExpires = $objAdapter.DHCPLeaseExpires $strLeaseExpires = WMIDateStringToDate($utcLeaseExpires) Else $strLeaseExpires = "" EndIf $sMsg &= " DHCP lease expires: " & $strLeaseExpires & @CRLF $sMsg &= @CRLF $sMsg &= " WINS" & @CRLF $sMsg &= " ----" & @CRLF $sMsg &= " Primary WINS server: " & $objAdapter.WINSPrimaryServer & @CRLF $sMsg &= " Secondary WINS server: " & $objAdapter.WINSSecondaryServer & @CRLF $sMsg &= @CRLF $n += 1 Next $hFile = FileOpen(@ScriptDir & "\IPConfigData.txt", 2) FileWrite($hFile, $sMsg) FileClose($hFile) Run('notepad.exe "' & @ScriptDir & "\IPConfigData.txt") Exit Func WMIDateStringToDate($utcDate) Return StringMid($utcDate, 5, 2) & "/" & _ StringMid($utcDate, 7, 2) & "/" & _ StringLeft($utcDate, 4) & " " & _ StringMid($utcDate, 9, 2) & ":" & _ StringMid($utcDate, 11, 2) & ":" & _ StringMid($utcDate, 13, 2) EndFunc ;==>WMIDateStringToDate P.S. Doh! Looks like Ptrex already posted almost the exact same code. Edited December 4, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
UEZ Posted December 4, 2007 Author Posted December 4, 2007 Sorry for the confusion. I saw it too late (copy & paste wrong lines) But it was still same issue because you can enter several DNSDomainSuffixSearchOrder items... I tested the script you posted -> that's what I searched for Thank you for your support. UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now