Jump to content

WMI and IPV6


 Share

Recommended Posts

HI

Another head scratched

Anyone solve how to get the IPV6 from WMI?

I followed the usual SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='" & GUICtrlRead($cboAdapters) & "'

get the index 

port it to 

Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )

All i can see is IPv4 addresses

My question is is there another place the IPv6 information is hiding? I configured my LAN with IPV6 and my wireless with IPv4 so I can see what shows.

Thanks in Advance.

PS. I did try google :(

 

Link to comment
Share on other sites

29 minutes ago, Dwalfware said:

3270 lines of code .... lol

The idea behind asking for help is to create a runable example of what it is not working.  And it is not asking us to work for you until you get the right solution...

Link to comment
Share on other sites

Hello, thank you and I found IPv6 in WMI

It seems you have to have an enabled and connected network card to see the interface. Now all what is missing is the DNS for IPv6 

below is the script and sorry for any inconvenience

 

#include <Array.au3>
Global $SelectedAdapters[1][37], $AdaptorInfo[1][21]
$SelectedAdapters[0][0] = 0
$AdaptorInfo[0][0] = 0

; USE Local Area Connection or Wireless Network Connection  @ _GetSelectedNIC()

_GETcurrentNICinfo()

;------------------------------------------------------------------------------------------------------------
; ------------------------
; GET THE NIC INFO
; ------------------------
Func _GETcurrentNICinfo()
$AdaptorInfo[0][0]
Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:NIC get Error" & @CRLF)
ConsoleWrite( "Not completed error" & @CRLF)
ConsoleWrite( " " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf
; ..................................................
If IsObj($query) Then
For $objItem In $query
; ...........................................
$AdaptorInfo[0][0] = $objItem.DHCPEnabled
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
$AdaptorInfo[0][1] = $objItem.DHCPServer
; ...........................................
If UBound($objItem.IPAddress) = 0 then
$AdaptorInfo[0][2] = ""
$AdaptorInfo[0][3] = ""
$AdaptorInfo[0][19] = ""
Endif
If UBound($objItem.IPAddress) = 1 then                    ; If only IPv4
$String0 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$AdaptorInfo[0][3] = ""
Endif
If UBound($objItem.IPAddress) = 2 then                    ; If Both IPV4 and IPV6
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][3] = $objItem.IPAddress[$String1]
Endif
If UBound($objItem.IPAddress) = 3 then                    ; If Both IPV4 and IPV6
$String00 = UBound($objItem.IPAddress) -3
$AdaptorInfo[0][2] = $objItem.IPAddress[$String00]
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][3] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][19] = $objItem.IPAddress[$String1]
Endif
; ...........................................
; ...........................................
If UBound($objItem.IPSubnet) = 0 then
$AdaptorInfo[0][4] = ""
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 1 then                    ; If Subnet
$String0 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 2 then                    ; If more than one Subnet
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String1]
Endif
If UBound($objItem.IPSubnet) = 3 then                    ; If more than one Subnet
$String00 = UBound($objItem.IPSubnet) -3
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String00]
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][20] = $objItem.IPSubnet[$String1]
Endif
;$AdaptorInfo[0][4] = $objItem.IPSubnet[0]
;$AdaptorInfo[0][5] = $objItem.IPSubnet[1]
; ...........................................
; ...........................................
If UBound($objItem.DefaultIPGateway) = 0 then
$AdaptorInfo[0][6] = ""
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 1 then                    ; Get the Default Gateway
$String0 = UBound($objItem.DefaultIPGateway) - 1
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 2 then                     ; If more than one Gateway
$String0 = UBound($objItem.DefaultIPGateway) -2
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$String1 = UBound($objItem.DefaultIPGateway) -1
$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[$String1]
Endif
;$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[0]
;$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[1]
; ...........................................
; ...........................................

If UBound($objItem.DNSServerSearchOrder) = 0 then
$AdaptorInfo[0][7] = ""
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 1 then                    ; If one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 2 then                    ; If more than one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 3 then                    ; If more than one DNS
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 4 then                    ; If more than one DNS
$String000 = UBound($objItem.DNSServerSearchOrder) -4
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String000]
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][18] = $objItem.DNSServerSearchOrder[$String1]
Endif
;$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[0]
;$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[1]
; ...........................................
; ...........................................
$AdaptorInfo[0][9] = $objItem.MACAddress
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
; ...........................................
Next
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "WARNING:WINDOWS NIC INFO NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error or not true" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf

; .................................................. ADD ON INFO
$AdaptorInfo[0][10] = @LogonDomain
$AdaptorInfo[0][11] = @LogonServer
$AdaptorInfo[0][14] = @LogonDNSDomain
$AdaptorInfo[0][15] = @ComputerName
; ..................................................
; ---------------------------------------------
;  DISPLAY THE NIC INFO
; ---------------------------------------------
ConsoleWrite("NETWORK ADAPTOR INFORMATION" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite( $SelectedAdapters[0][7] & @CRLF)
If $SelectedAdapters[0][23] = 0 then
ConsoleWrite("NIC Status: Disabled" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 7 then
ConsoleWrite("NIC Status: Enabled no Connection" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 2 then
ConsoleWrite("NIC Status: Connected ok" & @CRLF)
Endif
ConsoleWrite("NIC Connected: " & $SelectedAdapters[0][24] & @CRLF)
ConsoleWrite("DHCP Enabled: " & $AdaptorInfo[0][0] & @CRLF)
ConsoleWrite("DHCP Lease Ex: " & $AdaptorInfo[0][13] & @CRLF)
ConsoleWrite("DHCP Server: " & $AdaptorInfo[0][1] & @CRLF)
ConsoleWrite("IPV4 Address1: " & $AdaptorInfo[0][2] & @CRLF)
ConsoleWrite("IPV6 Address1: " & $AdaptorInfo[0][3] & @CRLF)
ConsoleWrite("IPV6 Address2: " & $AdaptorInfo[0][19] & @CRLF)
ConsoleWrite("Subnet IPv4: " & $AdaptorInfo[0][4] & @CRLF)
ConsoleWrite("Subnet Prefix IPv4: " & $AdaptorInfo[0][5] & @CRLF)
ConsoleWrite("Subnet Prefix IPv6: " & $AdaptorInfo[0][5] & @CRLF)
ConsoleWrite("Gateway IPv4: " & $AdaptorInfo[0][6] & @CRLF)
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][16] & @CRLF)
ConsoleWrite("DNS Primary IPv4: " & $AdaptorInfo[0][7] & @CRLF)
ConsoleWrite("DNS Secondry IPv4: " & $AdaptorInfo[0][8] & @CRLF)
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
ConsoleWrite("MAC Address: " & $AdaptorInfo[0][9] & @CRLF)
ConsoleWrite("Logon Domain: " & $AdaptorInfo[0][10] & @CRLF)
ConsoleWrite("Logon Server: " & $AdaptorInfo[0][11] & @CRLF)
ConsoleWrite("DNS Server: " & $AdaptorInfo[0][14] & @CRLF)
ConsoleWrite("Computer Name: " & $AdaptorInfo[0][15] & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
return
; ..................................................
; AVALIBLE MS INFO
;  string   Caption;
;  string   Description;
;  string   SettingID;
;  boolean  ArpAlwaysSourceRoute;
;  boolean  ArpUseEtherSNAP;
;  string   DatabasePath;
;  boolean  DeadGWDetectEnabled;
;  string   DefaultIPGateway[];
;  uint8    DefaultTOS;
;  uint8    DefaultTTL;
;  boolean  DHCPEnabled;
;  datetime DHCPLeaseExpires;
;  datetime DHCPLeaseObtained;
;  string   DHCPServer;
;  string   DNSDomain;
;  string   DNSDomainSuffixSearchOrder[];
;  boolean  DNSEnabledForWINSResolution;
;  string   DNSHostName;
;  string   DNSServerSearchOrder[];
;  boolean  DomainDNSRegistrationEnabled;
;  uint32   ForwardBufferMemory;
;  boolean  FullDNSRegistrationEnabled;
;  uint16   GatewayCostMetric[];
;  uint8    IGMPLevel;
;  uint32   Index;
;  uint32   InterfaceIndex;
;  string   IPAddress[];
;  uint32   IPConnectionMetric;
;  boolean  IPEnabled;
;  boolean  IPFilterSecurityEnabled;
;  boolean  IPPortSecurityEnabled;
;  string   IPSecPermitIPProtocols[];
;  string   IPSecPermitTCPPorts[];
;  string   IPSecPermitUDPPorts[];
;  string   IPSubnet[];
;  boolean  IPUseZeroBroadcast;
;  string   IPXAddress;
;  boolean  IPXEnabled;
;  uint32   IPXFrameType[];
;  uint32   IPXMediaType;
;  string   IPXNetworkNumber[];
;  string   IPXVirtualNetNumber;
;  uint32   KeepAliveInterval;
;  uint32   KeepAliveTime;
;  string   MACAddress;
;  uint32   MTU;
;  uint32   NumForwardPackets;
;  boolean  PMTUBHDetectEnabled;
;  boolean  PMTUDiscoveryEnabled;
;  string   ServiceName;
;  uint32   TcpipNetbiosOptions;
;  uint32   TcpMaxConnectRetransmissions;
;  uint32   TcpMaxDataRetransmissions;
;  uint32   TcpNumConnections;
;  boolean  TcpUseRFC1122UrgentPointer;
;  uint16   TcpWindowSize;
;  boolean  WINSEnableLMHostsLookup;
;  string   WINSHostLookupFile;
;  string   WINSPrimaryServer;
;  string   WINSScopeID;
;  string   WINSSecondaryServer;
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------
; --------------------------
; GET THE WMI SELECT ADDAPTORS INFO
; --------------------------
Func _GetSelectedNIC()
Local $o_WMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Local Area Connection'", "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC get Error" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
Return
EndIf
; ..................................................
For $objItem In $query
If IsObj($query) Then
;$SelectedAdapters[0][0] = $objItem.AdapterTypeID
;$SelectedAdapters[0][1] = $objItem.AutoSense
$SelectedAdapters[0][2] = $objItem.Availability
;$SelectedAdapters[0][3] = $objItem.Caption
;$SelectedAdapters[0][4] = $objItem.ConfigManagerErrorCode
;$SelectedAdapters[0][5] = $objItem.ConfigManagerUserConfig
;;;$SelectedAdapters[0][6] = $objItem.reationClassName
$SelectedAdapters[0][7] = $objItem.Description
;$SelectedAdapters[0][8] = $objItem.ErrorCleared
;$SelectedAdapters[0][9] = $objItem.ErrorDescription
;$SelectedAdapters[0][10] = $objItem.GUID
$SelectedAdapters[0][11] = $objItem.Index
;$SelectedAdapters[0][12] = $objItem.InstallDate
;$SelectedAdapters[0][13] = $objItem.Installed
;$SelectedAdapters[0][14] = $objItem.InterfaceIndex
;$SelectedAdapters[0][15] = $objItem.LastErrorCode
;$SelectedAdapters[0][16] = $objItem.MACAddress
;$SelectedAdapters[0][17] = $objItem.Manufacturer
;$SelectedAdapters[0][18] = $objItem.MaxNumberControlled
;$SelectedAdapters[0][19] = $objItem.MaxSpeed
;$SelectedAdapters[0][21] = $objItem.Name
$SelectedAdapters[0][22] = $objItem.NetConnectionID
$SelectedAdapters[0][23] = $objItem.NetConnectionStatus
$SelectedAdapters[0][24] = $objItem.NetEnabled
;;;$SelectedAdapters[0][25] = $objItem.NetworkAddresses[0]
;$SelectedAdapters[0][26] = $objItem.PermanentAddress
;$SelectedAdapters[0][27] = $objItem.PhysicalAdapter
;$SelectedAdapters[0][28] = $objItem.PNPDeviceID
;;;$SelectedAdapters[0][29] = $objItem.PowerManagementCapabilities[0]
;$SelectedAdapters[0][30] = $objItem.PowerManagementSupported
;$SelectedAdapters[0][31] = $objItem.ProductName
;$SelectedAdapters[0][32] = $objItem.ServiceName
;$SelectedAdapters[0][33] = $objItem.Speed
;$SelectedAdapters[0][34] = $objItem.Status
;$SelectedAdapters[0][35] = $objItem.StatusInfo
;$SelectedAdapters[0][36] = $objItem.SystemCreationClassName
;;;$SelectedAdapters[0][37] = $objItem.SystemName
;;;$SelectedAdapters[0][38] = $objItem.TimeOfLastReset
;ConsoleWrite("DEBUG2: " & ubound($objItem.NetworkAddresses) & @CRLF)
;_ArrayDisplay($aArrayExploded2, "DEBUG:")
; ..................................................
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
Endif
; ..................................................
Next
$Exitloop1 = 0
; RETURN JUST THE INDEX OF THE SELECTED ADAPTOR USED TO SEARCH THE INFO OF CARD
Return $SelectedAdapters[0][11]
; ..................................................
EndFunc

 

Edited by Dwalfware
Link to comment
Share on other sites

I am missing these , i setup google IPv6 DNS on the NIC and cant find it "2001:4860:4860::8888"

All the other IP and Gateway show for IPv6? Lost. 

ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
Edited by Dwalfware
Link to comment
Share on other sites

My Output / I changed some info but as you can see no DNS IPv6 :(

 

Realtek Wi-Fi Adapter
NIC Status: Connected ok
NIC Connected: True
DHCP Enabled: True
DHCP Lease Ex: 20180222025612.000000-480
DHCP Server: 192.168.10.1
IPV4 Address1: 192.168.10.100
IPV6 Address1: fe80::
IPV6 Address2: fda8:6c3:ce53:a890::2
Subnet IPv4: 255.255.255.0
Subnet Prefix IPv4: 64
Subnet Prefix IPv6: 64
Gateway IPv4: 192.168.10.1
Gateway IPv6: fda8:6c3:ce53:a890::5
DNS Primary IPv4: 8.8.8.8
DNS Secondry IPv4: 8.8.4.4
DNS Primary IPv6: 
DNS Secondry IPv6: 

MAC Address: 74:00:00:00:00
Logon Domain: PC
Logon Server: \\PC
DNS Server: 
Computer Name: PC

Link to comment
Share on other sites

9 hours ago, Dwalfware said:

I configured my LAN with IPV6 and my wireless with IPv4

 

5 hours ago, Dwalfware said:

Realtek Wi-Fi Adapter

So, what you're getting is the Wi-Fi Network Adapter, which should not be confifured with IPV6 IP, isn't it? :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

9 hours ago, FrancescoDiMuro said:

 

So, what you're getting is the Wi-Fi Network Adapter, which should not be confifured with IPV6 IP, isn't it? :)

ahhaha You're right :lol:

That is some crazy setup,  So I see on wifi NIC you see everything and of course does not work,

Then when I plugged the LAN in it retuns only one gateway IPv6 and skips the Ipv4 gateway.

But still no DNS entry. Do you think they hide it under some other setting?

 

Great now I need to filter lol

 

My result does not show "2001:4860:4860::8888" for Primary DNS

 

NETWORK ADAPTOR INFORMATION
************************************************************
Realtek PCIe FE Family Controller
NIC Status: Connected ok
NIC Connected: True
DHCP Enabled: False
DHCP Lease Ex: 
DHCP Server: 
IPV4 Address1: 192.168.10.10
IPV6 Address1: fe80::5445:3a3b:48bb:f246
IPV6 Address2: fda8:6c3:ce53:a890::3
Subnet IPv4: 255.255.255.0
Subnet Prefix IPv4: 64
Subnet Prefix IPv6: 64
Gateway IPv4: fda8:6c3:ce53:a890::5
Gateway IPv6: 
DNS Primary IPv4: 
DNS Secondry IPv4: 
DNS Primary IPv6: 
DNS Secondry IPv6: 
MAC Address: EC:00:00:00:00
Logon Domain: PC
Logon Server: \\PC
DNS Server: 
Computer Name: PC
************************************************************

 

Edited by Dwalfware
Link to comment
Share on other sites

I filtered the gateway, doing more searches for the DNS next

New Code below.

 

#include <Array.au3>
Global $SelectedAdapters[1][37], $AdaptorInfo[1][21]
$SelectedAdapters[0][0] = 0
$AdaptorInfo[0][0] = 0

; USE Local Area Connection or Wireless Network Connection  @ _GetSelectedNIC()

_GETcurrentNICinfo()

;------------------------------------------------------------------------------------------------------------
; ------------------------
; GET THE NIC INFO
; ------------------------
Func _GETcurrentNICinfo()
$AdaptorInfo[0][0]
Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:NIC get Error" & @CRLF)
ConsoleWrite( "Not completed error" & @CRLF)
ConsoleWrite( " " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf
; ..................................................
If IsObj($query) Then
For $objItem In $query
; ...........................................
$AdaptorInfo[0][0] = $objItem.DHCPEnabled
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
$AdaptorInfo[0][1] = $objItem.DHCPServer
; ...........................................
If UBound($objItem.IPAddress) = 0 then
$AdaptorInfo[0][2] = ""
$AdaptorInfo[0][3] = ""
$AdaptorInfo[0][19] = ""
Endif
If UBound($objItem.IPAddress) = 1 then                    ; If only IPv4
$String0 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$AdaptorInfo[0][3] = ""
Endif
If UBound($objItem.IPAddress) = 2 then                    ; If Both IPV4 and IPV6
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][3] = $objItem.IPAddress[$String1]
Endif
If UBound($objItem.IPAddress) = 3 then                    ; If Both IPV4 and IPV6
$String00 = UBound($objItem.IPAddress) -3
$AdaptorInfo[0][2] = $objItem.IPAddress[$String00]
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][3] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][19] = $objItem.IPAddress[$String1]
Endif
; ...........................................
; ...........................................
If UBound($objItem.IPSubnet) = 0 then
$AdaptorInfo[0][4] = ""
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 1 then                    ; If Subnet
$String0 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 2 then                    ; If more than one Subnet
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String1]
Endif
If UBound($objItem.IPSubnet) = 3 then                    ; If more than one Subnet
$String00 = UBound($objItem.IPSubnet) -3
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String00]
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][20] = $objItem.IPSubnet[$String1]
Endif
;$AdaptorInfo[0][4] = $objItem.IPSubnet[0]
;$AdaptorInfo[0][5] = $objItem.IPSubnet[1]
; ...........................................
; ...........................................
If UBound($objItem.DefaultIPGateway) = 0 then
$AdaptorInfo[0][6] = ""
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 1 then                    ; Get the Default Gateway
$String0 = UBound($objItem.DefaultIPGateway) - 1
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 2 then                     ; If more than one Gateway
$String0 = UBound($objItem.DefaultIPGateway) -2
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$String1 = UBound($objItem.DefaultIPGateway) -1
$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[$String1]
Endif
;$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[0]
;$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[1]
; ...........................................
; ...........................................
ConsoleWrite("DEBUG: " & UBound($objItem.IPAddress) & @CRLF)
If UBound($objItem.DNSServerSearchOrder) = 0 then
$AdaptorInfo[0][7] = ""
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 1 then                    ; If one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 2 then                    ; If more than one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 3 then                    ; If more than one DNS
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 4 then                    ; If more than one DNS
$String000 = UBound($objItem.DNSServerSearchOrder) -4
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String000]
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][18] = $objItem.DNSServerSearchOrder[$String1]
Endif
;$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[0]
;$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[1]
; ...........................................
; ...........................................
$AdaptorInfo[0][9] = $objItem.MACAddress
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
; ...........................................
Next
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "WARNING:WINDOWS NIC INFO NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error or not true" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf

; .................................................. ADD ON INFO
$AdaptorInfo[0][10] = @LogonDomain
$AdaptorInfo[0][11] = @LogonServer
$AdaptorInfo[0][14] = @LogonDNSDomain
$AdaptorInfo[0][15] = @ComputerName
; ..................................................
; ---------------------------------------------
;  DISPLAY THE NIC INFO
; ---------------------------------------------
ConsoleWrite("NETWORK ADAPTOR INFORMATION" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite( $SelectedAdapters[0][7] & @CRLF)
If $SelectedAdapters[0][23] = 0 then
ConsoleWrite("NIC Status: Disabled" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 7 then
ConsoleWrite("NIC Status: Enabled no Connection" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 2 then
ConsoleWrite("NIC Status: Connected ok" & @CRLF)
Endif
ConsoleWrite("NIC Connected: " & $SelectedAdapters[0][24] & @CRLF)
ConsoleWrite("DHCP Enabled: " & $AdaptorInfo[0][0] & @CRLF)
ConsoleWrite("DHCP Lease Ex: " & $AdaptorInfo[0][13] & @CRLF)
ConsoleWrite("DHCP Server: " & $AdaptorInfo[0][1] & @CRLF)
ConsoleWrite("IPV4 Address1: " & $AdaptorInfo[0][2] & @CRLF)
ConsoleWrite("IPV6 Address1: " & $AdaptorInfo[0][3] & @CRLF)
ConsoleWrite("IPV6 Address2: " & $AdaptorInfo[0][19] & @CRLF)
ConsoleWrite("Subnet IPv4: " & $AdaptorInfo[0][4] & @CRLF)
ConsoleWrite("Subnet Prefix IPv4: " & $AdaptorInfo[0][5] & @CRLF)
ConsoleWrite("Subnet Prefix IPv6: " & $AdaptorInfo[0][5] & @CRLF)
Local $aTestedDNSIpv4 = StringRegExp($AdaptorInfo[0][6], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv4 = 1 Then
ConsoleWrite("Gateway IPv4: " & $AdaptorInfo[0][6] & @CRLF)
Else
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][6] & @CRLF)
Endif
Local $aTestedDNSIpv6 = StringRegExp($AdaptorInfo[0][16], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv6 = 0 and NOT $AdaptorInfo[0][16] = "" Then
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][16] & @CRLF)
Endif
ConsoleWrite("DNS Primary IPv4: " & $AdaptorInfo[0][7] & @CRLF)
ConsoleWrite("DNS Secondry IPv4: " & $AdaptorInfo[0][8] & @CRLF)
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
ConsoleWrite("MAC Address: " & $AdaptorInfo[0][9] & @CRLF)
ConsoleWrite("Logon Domain: " & $AdaptorInfo[0][10] & @CRLF)
ConsoleWrite("Logon Server: " & $AdaptorInfo[0][11] & @CRLF)
ConsoleWrite("DNS Server: " & $AdaptorInfo[0][14] & @CRLF)
ConsoleWrite("Computer Name: " & $AdaptorInfo[0][15] & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
return
; ..................................................
; AVALIBLE MS INFO
;  string   Caption;
;  string   Description;
;  string   SettingID;
;  boolean  ArpAlwaysSourceRoute;
;  boolean  ArpUseEtherSNAP;
;  string   DatabasePath;
;  boolean  DeadGWDetectEnabled;
;  string   DefaultIPGateway[];
;  uint8    DefaultTOS;
;  uint8    DefaultTTL;
;  boolean  DHCPEnabled;
;  datetime DHCPLeaseExpires;
;  datetime DHCPLeaseObtained;
;  string   DHCPServer;
;  string   DNSDomain;
;  string   DNSDomainSuffixSearchOrder[];
;  boolean  DNSEnabledForWINSResolution;
;  string   DNSHostName;
;  string   DNSServerSearchOrder[];
;  boolean  DomainDNSRegistrationEnabled;
;  uint32   ForwardBufferMemory;
;  boolean  FullDNSRegistrationEnabled;
;  uint16   GatewayCostMetric[];
;  uint8    IGMPLevel;
;  uint32   Index;
;  uint32   InterfaceIndex;
;  string   IPAddress[];
;  uint32   IPConnectionMetric;
;  boolean  IPEnabled;
;  boolean  IPFilterSecurityEnabled;
;  boolean  IPPortSecurityEnabled;
;  string   IPSecPermitIPProtocols[];
;  string   IPSecPermitTCPPorts[];
;  string   IPSecPermitUDPPorts[];
;  string   IPSubnet[];
;  boolean  IPUseZeroBroadcast;
;  string   IPXAddress;
;  boolean  IPXEnabled;
;  uint32   IPXFrameType[];
;  uint32   IPXMediaType;
;  string   IPXNetworkNumber[];
;  string   IPXVirtualNetNumber;
;  uint32   KeepAliveInterval;
;  uint32   KeepAliveTime;
;  string   MACAddress;
;  uint32   MTU;
;  uint32   NumForwardPackets;
;  boolean  PMTUBHDetectEnabled;
;  boolean  PMTUDiscoveryEnabled;
;  string   ServiceName;
;  uint32   TcpipNetbiosOptions;
;  uint32   TcpMaxConnectRetransmissions;
;  uint32   TcpMaxDataRetransmissions;
;  uint32   TcpNumConnections;
;  boolean  TcpUseRFC1122UrgentPointer;
;  uint16   TcpWindowSize;
;  boolean  WINSEnableLMHostsLookup;
;  string   WINSHostLookupFile;
;  string   WINSPrimaryServer;
;  string   WINSScopeID;
;  string   WINSSecondaryServer;
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------
; --------------------------
; GET THE WMI SELECT ADDAPTORS INFO
; --------------------------
Func _GetSelectedNIC()
Local $o_WMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
;Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Local Area Connection'", "WQL", 0x30 )
Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Wireless Network Connection'", "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC get Error" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
Return
EndIf
; ..................................................
For $objItem In $query
If IsObj($query) Then
;$SelectedAdapters[0][0] = $objItem.AdapterTypeID
;$SelectedAdapters[0][1] = $objItem.AutoSense
$SelectedAdapters[0][2] = $objItem.Availability
;$SelectedAdapters[0][3] = $objItem.Caption
;$SelectedAdapters[0][4] = $objItem.ConfigManagerErrorCode
;$SelectedAdapters[0][5] = $objItem.ConfigManagerUserConfig
;;;$SelectedAdapters[0][6] = $objItem.reationClassName
$SelectedAdapters[0][7] = $objItem.Description
;$SelectedAdapters[0][8] = $objItem.ErrorCleared
;$SelectedAdapters[0][9] = $objItem.ErrorDescription
;$SelectedAdapters[0][10] = $objItem.GUID
$SelectedAdapters[0][11] = $objItem.Index
;$SelectedAdapters[0][12] = $objItem.InstallDate
;$SelectedAdapters[0][13] = $objItem.Installed
;$SelectedAdapters[0][14] = $objItem.InterfaceIndex
;$SelectedAdapters[0][15] = $objItem.LastErrorCode
;$SelectedAdapters[0][16] = $objItem.MACAddress
;$SelectedAdapters[0][17] = $objItem.Manufacturer
;$SelectedAdapters[0][18] = $objItem.MaxNumberControlled
;$SelectedAdapters[0][19] = $objItem.MaxSpeed
;$SelectedAdapters[0][21] = $objItem.Name
$SelectedAdapters[0][22] = $objItem.NetConnectionID
$SelectedAdapters[0][23] = $objItem.NetConnectionStatus
$SelectedAdapters[0][24] = $objItem.NetEnabled
;;;$SelectedAdapters[0][25] = $objItem.NetworkAddresses[0]
;$SelectedAdapters[0][26] = $objItem.PermanentAddress
;$SelectedAdapters[0][27] = $objItem.PhysicalAdapter
;$SelectedAdapters[0][28] = $objItem.PNPDeviceID
;;;$SelectedAdapters[0][29] = $objItem.PowerManagementCapabilities[0]
;$SelectedAdapters[0][30] = $objItem.PowerManagementSupported
;$SelectedAdapters[0][31] = $objItem.ProductName
;$SelectedAdapters[0][32] = $objItem.ServiceName
;$SelectedAdapters[0][33] = $objItem.Speed
;$SelectedAdapters[0][34] = $objItem.Status
;$SelectedAdapters[0][35] = $objItem.StatusInfo
;$SelectedAdapters[0][36] = $objItem.SystemCreationClassName
;;;$SelectedAdapters[0][37] = $objItem.SystemName
;;;$SelectedAdapters[0][38] = $objItem.TimeOfLastReset
;ConsoleWrite("DEBUG2: " & ubound($objItem.NetworkAddresses) & @CRLF)
;_ArrayDisplay($aArrayExploded2, "DEBUG:")
; ..................................................
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
Endif
; ..................................................
Next
$Exitloop1 = 0
; RETURN JUST THE INDEX OF THE SELECTED ADAPTOR USED TO SEARCH THE INFO OF CARD
Return $SelectedAdapters[0][11]
; ..................................................
EndFunc

 

Link to comment
Share on other sites

OK so it looks like WMI does not have DNS IPv6 settings. I hacked it from the GUID and got it in the registery

So I found it in the register from an article.  https://blog.westmonroepartners.com/alternate-network-configuration-using-windows-scripting-host/

Now onto the next, Alternative IP configuration. Does auto it have a HEX converter?

Here is the new script.  Enjoy :D

#include <String.au3>
#include <Array.au3>
Global $SelectedAdapters[1][37], $AdaptorInfo[1][21]
$SelectedAdapters[0][0] = 0
$AdaptorInfo[0][0] = 0

; USE Local Area Connection or Wireless Network Connection  @ _GetSelectedNIC()

_GETcurrentNICinfo()

;------------------------------------------------------------------------------------------------------------
; ------------------------
; GET THE NIC INFO
; ------------------------
Func _GETcurrentNICinfo()
$AdaptorInfo[0][0]
Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:NIC get Error" & @CRLF)
ConsoleWrite( "Not completed error" & @CRLF)
ConsoleWrite( " " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf
; ..................................................
If IsObj($query) Then
For $objItem In $query
; ...........................................
$AdaptorInfo[0][0] = $objItem.DHCPEnabled
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
$AdaptorInfo[0][1] = $objItem.DHCPServer
; ...........................................
If UBound($objItem.IPAddress) = 0 then
$AdaptorInfo[0][2] = ""
$AdaptorInfo[0][3] = ""
$AdaptorInfo[0][19] = ""
Endif
If UBound($objItem.IPAddress) = 1 then                    ; If only IPv4
$String0 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$AdaptorInfo[0][3] = ""
Endif
If UBound($objItem.IPAddress) = 2 then                    ; If Both IPV4 and IPV6
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][3] = $objItem.IPAddress[$String1]
Endif
If UBound($objItem.IPAddress) = 3 then                    ; If Both IPV4 and IPV6
$String00 = UBound($objItem.IPAddress) -3
$AdaptorInfo[0][2] = $objItem.IPAddress[$String00]
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][3] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][19] = $objItem.IPAddress[$String1]
Endif
; ...........................................
; ...........................................
If UBound($objItem.IPSubnet) = 0 then
$AdaptorInfo[0][4] = ""
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 1 then                    ; If Subnet
$String0 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 2 then                    ; If more than one Subnet
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String1]
Endif
If UBound($objItem.IPSubnet) = 3 then                    ; If more than one Subnet
$String00 = UBound($objItem.IPSubnet) -3
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String00]
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][20] = $objItem.IPSubnet[$String1]
Endif
;$AdaptorInfo[0][4] = $objItem.IPSubnet[0]
;$AdaptorInfo[0][5] = $objItem.IPSubnet[1]
; ...........................................
; ...........................................
If UBound($objItem.DefaultIPGateway) = 0 then
$AdaptorInfo[0][6] = ""
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 1 then                    ; Get the Default Gateway
$String0 = UBound($objItem.DefaultIPGateway) - 1
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 2 then                     ; If more than one Gateway
$String0 = UBound($objItem.DefaultIPGateway) -2
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$String1 = UBound($objItem.DefaultIPGateway) -1
$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[$String1]
Endif
;$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[0]
;$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[1]
; ...........................................
; ...........................................
ConsoleWrite("DEBUG0: " & UBound($objItem.DNSServerSearchOrder) & @CRLF)
If UBound($objItem.DNSServerSearchOrder) = 0 then
$AdaptorInfo[0][7] = ""
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 1 then                    ; If one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 2 then                    ; If more than one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 3 then                    ; If more than one DNS
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 4 then                    ; If more than one DNS
$String000 = UBound($objItem.DNSServerSearchOrder) -4
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String000]
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][18] = $objItem.DNSServerSearchOrder[$String1]
Endif
;$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[0]
;$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[1]
; ...........................................
; ...........................................
$AdaptorInfo[0][9] = $objItem.MACAddress
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
; ...........................................
Next
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "WARNING:WINDOWS NIC INFO NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error or not true" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf

; .................................................. ADD ON INFO
$AdaptorInfo[0][10] = @LogonDomain
$AdaptorInfo[0][11] = @LogonServer
$AdaptorInfo[0][14] = @LogonDNSDomain
$AdaptorInfo[0][15] = @ComputerName
; ..................................................
; ---------------------------------------------
;  DISPLAY THE NIC INFO
; ---------------------------------------------
ConsoleWrite("NETWORK ADAPTOR INFORMATION" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite( $SelectedAdapters[0][7] & @CRLF)
If $SelectedAdapters[0][23] = 0 then
ConsoleWrite("NIC Status: Disabled" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 7 then
ConsoleWrite("NIC Status: Enabled no Connection" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 2 then
ConsoleWrite("NIC Status: Connected ok" & @CRLF)
Endif
ConsoleWrite("NIC Connected: " & $SelectedAdapters[0][24] & @CRLF)
ConsoleWrite("DHCP Enabled: " & $AdaptorInfo[0][0] & @CRLF)
ConsoleWrite("DHCP Lease Ex: " & $AdaptorInfo[0][13] & @CRLF)
ConsoleWrite("DHCP Server: " & $AdaptorInfo[0][1] & @CRLF)
ConsoleWrite("IPV4 Address1: " & $AdaptorInfo[0][2] & @CRLF)
ConsoleWrite("IPV6 Address1: " & $AdaptorInfo[0][3] & @CRLF)
ConsoleWrite("IPV6 Address2: " & $AdaptorInfo[0][19] & @CRLF)
ConsoleWrite("Subnet IPv4: " & $AdaptorInfo[0][4] & @CRLF)
ConsoleWrite("Subnet Prefix IPv4: " & $AdaptorInfo[0][5] & @CRLF)
ConsoleWrite("Subnet Prefix IPv6: " & $AdaptorInfo[0][5] & @CRLF)
Local $aTestedDNSIpv4 = StringRegExp($AdaptorInfo[0][6], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv4 = 1 Then
ConsoleWrite("Gateway IPv4: " & $AdaptorInfo[0][6] & @CRLF)
Else
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][6] & @CRLF)
Endif
Local $aTestedDNSIpv6 = StringRegExp($AdaptorInfo[0][16], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv6 = 0 and NOT $AdaptorInfo[0][16] = "" Then
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][16] & @CRLF)
Endif
ConsoleWrite("DNS Primary IPv4: " & $AdaptorInfo[0][7] & @CRLF)
ConsoleWrite("DNS Secondry IPv4: " & $AdaptorInfo[0][8] & @CRLF)
; .............................................................
If $AdaptorInfo[0][17] = "" or $AdaptorInfo[0][18] = "" Then
Local $sNameServer = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\Interfaces\" & $SelectedAdapters[0][10] , "NameServer")
Local $aDNSIPv6array = _StringExplode($sNameServer, ",", 0)
;;_ArrayDisplay($aDNSIPv6array, "DEBUG:")
If UBound($aDNSIPv6array) = 1 then
$AdaptorInfo[0][17] = $aDNSIPv6array[UBound($aDNSIPv6array) -1]
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
Endif
If UBound($aDNSIPv6array) = 2 then
$AdaptorInfo[0][17] = $aDNSIPv6array[UBound($aDNSIPv6array) -2]
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
$AdaptorInfo[0][18] = $aDNSIPv6array[UBound($aDNSIPv6array) -1]
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
Endif
Endif
; .............................................................
ConsoleWrite("MAC Address: " & $AdaptorInfo[0][9] & @CRLF)
ConsoleWrite("Logon Domain: " & $AdaptorInfo[0][10] & @CRLF)
ConsoleWrite("Logon Server: " & $AdaptorInfo[0][11] & @CRLF)
ConsoleWrite("DNS Server: " & $AdaptorInfo[0][14] & @CRLF)
ConsoleWrite("Computer Name: " & $AdaptorInfo[0][15] & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
return
; ..................................................
; AVALIBLE MS INFO
;  string   Caption;
;  string   Description;
;  string   SettingID;
;  boolean  ArpAlwaysSourceRoute;
;  boolean  ArpUseEtherSNAP;
;  string   DatabasePath;
;  boolean  DeadGWDetectEnabled;
;  string   DefaultIPGateway[];
;  uint8    DefaultTOS;
;  uint8    DefaultTTL;
;  boolean  DHCPEnabled;
;  datetime DHCPLeaseExpires;
;  datetime DHCPLeaseObtained;
;  string   DHCPServer;
;  string   DNSDomain;
;  string   DNSDomainSuffixSearchOrder[];
;  boolean  DNSEnabledForWINSResolution;
;  string   DNSHostName;
;  string   DNSServerSearchOrder[];
;  boolean  DomainDNSRegistrationEnabled;
;  uint32   ForwardBufferMemory;
;  boolean  FullDNSRegistrationEnabled;
;  uint16   GatewayCostMetric[];
;  uint8    IGMPLevel;
;  uint32   Index;
;  uint32   InterfaceIndex;
;  string   IPAddress[];
;  uint32   IPConnectionMetric;
;  boolean  IPEnabled;
;  boolean  IPFilterSecurityEnabled;
;  boolean  IPPortSecurityEnabled;
;  string   IPSecPermitIPProtocols[];
;  string   IPSecPermitTCPPorts[];
;  string   IPSecPermitUDPPorts[];
;  string   IPSubnet[];
;  boolean  IPUseZeroBroadcast;
;  string   IPXAddress;
;  boolean  IPXEnabled;
;  uint32   IPXFrameType[];
;  uint32   IPXMediaType;
;  string   IPXNetworkNumber[];
;  string   IPXVirtualNetNumber;
;  uint32   KeepAliveInterval;
;  uint32   KeepAliveTime;
;  string   MACAddress;
;  uint32   MTU;
;  uint32   NumForwardPackets;
;  boolean  PMTUBHDetectEnabled;
;  boolean  PMTUDiscoveryEnabled;
;  string   ServiceName;
;  uint32   TcpipNetbiosOptions;
;  uint32   TcpMaxConnectRetransmissions;
;  uint32   TcpMaxDataRetransmissions;
;  uint32   TcpNumConnections;
;  boolean  TcpUseRFC1122UrgentPointer;
;  uint16   TcpWindowSize;
;  boolean  WINSEnableLMHostsLookup;
;  string   WINSHostLookupFile;
;  string   WINSPrimaryServer;
;  string   WINSScopeID;
;  string   WINSSecondaryServer;
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------
; --------------------------
; GET THE WMI SELECT ADDAPTORS INFO
; --------------------------
Func _GetSelectedNIC()
Local $o_WMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
;Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Local Area Connection'", "WQL", 0x30 )
Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Wireless Network Connection'", "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC get Error" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
Return
EndIf
; ..................................................
For $objItem In $query
If IsObj($query) Then
$SelectedAdapters[0][0] = $objItem.AdapterTypeID
$SelectedAdapters[0][1] = $objItem.AutoSense
$SelectedAdapters[0][2] = $objItem.Availability
$SelectedAdapters[0][3] = $objItem.Caption
$SelectedAdapters[0][4] = $objItem.ConfigManagerErrorCode
$SelectedAdapters[0][5] = $objItem.ConfigManagerUserConfig
;;;$SelectedAdapters[0][6] = $objItem.reationClassName
$SelectedAdapters[0][7] = $objItem.Description
;$SelectedAdapters[0][8] = $objItem.ErrorCleared
;$SelectedAdapters[0][9] = $objItem.ErrorDescription
$SelectedAdapters[0][10] = $objItem.GUID
$SelectedAdapters[0][11] = $objItem.Index
;$SelectedAdapters[0][12] = $objItem.InstallDate
;$SelectedAdapters[0][13] = $objItem.Installed
;$SelectedAdapters[0][14] = $objItem.InterfaceIndex
;$SelectedAdapters[0][15] = $objItem.LastErrorCode
;$SelectedAdapters[0][16] = $objItem.MACAddress
;$SelectedAdapters[0][17] = $objItem.Manufacturer
;$SelectedAdapters[0][18] = $objItem.MaxNumberControlled
;$SelectedAdapters[0][19] = $objItem.MaxSpeed
;$SelectedAdapters[0][21] = $objItem.Name
$SelectedAdapters[0][22] = $objItem.NetConnectionID
$SelectedAdapters[0][23] = $objItem.NetConnectionStatus
$SelectedAdapters[0][24] = $objItem.NetEnabled
ConsoleWrite("DEBUG2: " & UBound($objItem.NetworkAddresses) & @CRLF)
;;;$SelectedAdapters[0][25] = $objItem.NetworkAddresses[0]
ConsoleWrite("DEBUG3: " & UBound($objItem.PermanentAddress) & @CRLF)
;$SelectedAdapters[0][26] = $objItem.PermanentAddress
;$SelectedAdapters[0][27] = $objItem.PhysicalAdapter
;$SelectedAdapters[0][28] = $objItem.PNPDeviceID
;;;$SelectedAdapters[0][29] = $objItem.PowerManagementCapabilities[0]
;$SelectedAdapters[0][30] = $objItem.PowerManagementSupported
;$SelectedAdapters[0][31] = $objItem.ProductName
;$SelectedAdapters[0][32] = $objItem.ServiceName
;$SelectedAdapters[0][33] = $objItem.Speed
;$SelectedAdapters[0][34] = $objItem.Status
;$SelectedAdapters[0][35] = $objItem.StatusInfo
;$SelectedAdapters[0][36] = $objItem.SystemCreationClassName
;;;$SelectedAdapters[0][37] = $objItem.SystemName
;;;$SelectedAdapters[0][38] = $objItem.TimeOfLastReset
;ConsoleWrite("DEBUG2: " & ubound($objItem.NetworkAddresses) & @CRLF)
;_ArrayDisplay($SelectedAdapters, "DEBUG:")
; ..................................................
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
Endif
; ..................................................
Next
; RETURN JUST THE INDEX OF THE SELECTED ADAPTOR USED TO SEARCH THE INFO OF CARD
Return $SelectedAdapters[0][11]
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------

 

Link to comment
Share on other sites

10 minutes ago, Dwalfware said:

Does auto it have a HEX converter?

Convert to or from hex? Functions Dec, Hex come to my mind.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

10 hours ago, water said:

Convert to or from hex? Functions Dec, Hex come to my mind.

From HEX -  The key holds the Alternative IP Config for Ipv4 setup, I will give it a go and see how it goes. Thanks for Info. ;)

PS .. I like this TCPIP key, It also shows you an DHCP HINT Key. If you change to static it shows a HINT of what the DHCP will be before you change back.

Thanks for all the help. 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dhcp\Configurations\Alternate_{5C057CAC-80D1-471F-BBCF-FF16EAE415CA}    Key = Options

Alternate_{5C057CAC-80D1-471F-BBCF-FF16EAE415CA}  = from GUID

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\{5C057CAC-80D1-471F-BBCF-FF16EAE415CA} Key ActiveConfigurations

From GUID NIC

Win32_NetworkAdapter 
$objItem.GUID
Edited by Dwalfware
Link to comment
Share on other sites

I think I should have just exploded all the ips onto one array.  This bit of code will make your head hurt :P

This seems to work with Alternative IP config from HEX to DEC but have a strange SPACE in the array.

Bet its in that 96 

I think this might be a First for a script to get the ALTERNATIVE IP CONFIG FULLY

Lots of space for improvement.

Enjoy

 

#include <String.au3>
#include <Array.au3>
Global $SelectedAdapters[1][37], $AdaptorInfo[1][21]
$SelectedAdapters[0][0] = 0
$AdaptorInfo[0][0] = 0

; USE Local Area Connection or Wireless Network Connection  @ _GetSelectedNIC()

_GETcurrentNICinfo()

_GETcurrentNICAlt()

Func _GETcurrentNICAlt()
;ConsoleWrite( "************************************************************" & @CRLF)
Local $sString[1][200], $sString2[1][13], $xiii = 2, $xii = 1, $xi = 0, $xiiii = 0, $yi = 0
Local $aAltConfig = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\" & $SelectedAdapters[0][10] , "ActiveConfigurations")
;ConsoleWrite("************************************************************" & @CRLF)
;ConsoleWrite("" & $aAltConfig & @CRLF)
;ConsoleWrite("************************************************************" & @CRLF)
Local $aAltConfigDHCPHEX = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dhcp\Configurations\" & $aAltConfig, "Options")
;ConsoleWrite("************************************************************" & @CRLF)
;ConsoleWrite("" & $aAltConfigDHCPHEX & @CRLF)
;ConsoleWrite("************************************************************" & @CRLF)
Local $sHexCount = StringLen($aAltConfigDHCPHEX)
;ConsoleWrite("" & $sHexCount & @CRLF)
;ConsoleWrite("************************************************************" & @CRLF)
;ConsoleWrite("************************************************************" & @CRLF)
Local $sStringTrim = $aAltConfigDHCPHEX
$sStringTrim = StringTrimLeft($sStringTrim, 2)
Local $sString3 = ""
Local $sString4 = ""
Do
$sString[0][$xii] = StringLeft($sStringTrim, $xiii)
;ConsoleWrite("" & $sString[0][$xii] & @CRLF)
$sStringTrim = StringTrimLeft($sStringTrim, $xiii)
;ConsoleWrite("" & $sStringTrim & @CRLF)
Local $sHex = Dec($sString[0][$xii],0)
;ConsoleWrite("" & $sHex & @CRLF)
;ConsoleWrite("(" & $xii & ") " & "HEX:" & $sString[0][$xii] & "-DEC:" & $sHex & @CRLF)
If $xii > 96 Then
If $xi < 4 Then
$sString3 = $sString3 & $sHex & "."
;ConsoleWrite("DEBUG" & $sString3 & @CRLF)
Endif
If $xi >= 4 Then
$sString4 = $sString4 & $sHex & "."
;ConsoleWrite("DEBUG" & $sString3 & @CRLF)
Endif
Else
If $xi >= 4 Then
$sString3 = $sString3 & $sHex & "."
;;ConsoleWrite("DEBUG" & $sString3 & @CRLF)
Endif
Endif
$xii = $xii + 1
$xi = $xi + 1
$yi = $yi + 1
; ......................
If $xii <= 96 Then
If $xi = 8 Then
$xi = 0
If $yi = 24 Then
$yi = 0
$sString3 = StringTrimRight($sString3,1)
$sString2[0][$xiiii] = $sString3
;ConsoleWrite("Last 4 Oct=" & $sString2[0][$xiiii] & @CRLF)
$xiiii = $xiiii + 1
Endif
$sString3 = ""
Endif
Else
If $xi = 8 Then
$xi = 0
$sString3 = StringTrimRight($sString3,1)
$sString2[0][$xiiii] = $sString3
;ConsoleWrite("Last 4 Oct=" & $sString2[0][$xiiii] & @CRLF)
$xiiii = $xiiii + 1
$sString4 = StringTrimRight($sString4,1)
$sString2[0][$xiiii] = $sString4
;ConsoleWrite("Last 4 Oct=" & $sString2[0][$xiiii] & @CRLF)
$xiiii = $xiiii + 1
$sString3 = ""
$sString4 = ""
Endif
Endif
; ......................
;ConsoleWrite("************************************************************" & @CRLF)
Until $xii = number($sHexCount / 2)
;ConsoleWrite("************************************************************" & @CRLF)
;_ArrayDisplay($sString2, "DEBUG:")
;ConsoleWrite("************************************************************" & @CRLF)

For $Yii = 0 to UBound($sString2) -1
ConsoleWrite("NETWORK ALTERNATIVE IP CONFIG INFORMATION" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite("IP Address: " & $sString2[0][0] & @CRLF)
ConsoleWrite("Subnet: " & $sString2[0][1] & @CRLF)
ConsoleWrite("Gateway: " & $sString2[0][2] & @CRLF)
ConsoleWrite("DNS Primary: " & $sString2[0][3] & @CRLF)
ConsoleWrite("DNS Secondry: " & $sString2[0][5] & @CRLF)
ConsoleWrite("WINS Address1: " & $sString2[0][11] & @CRLF)
ConsoleWrite("WINS Address1: " & $sString2[0][12] & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Next

EndFunc

;------------------------------------------------------------------------------------------------------------
; ------------------------
; GET THE NIC INFO
; ------------------------
Func _GETcurrentNICinfo()
$AdaptorInfo[0][0]
Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:NIC get Error" & @CRLF)
ConsoleWrite( "Not completed error" & @CRLF)
ConsoleWrite( " " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf
; ..................................................
If IsObj($query) Then
For $objItem In $query
; ...........................................
$AdaptorInfo[0][0] = $objItem.DHCPEnabled
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
$AdaptorInfo[0][1] = $objItem.DHCPServer
; ...........................................
If UBound($objItem.IPAddress) = 0 then
$AdaptorInfo[0][2] = ""
$AdaptorInfo[0][3] = ""
$AdaptorInfo[0][19] = ""
Endif
If UBound($objItem.IPAddress) = 1 then                    ; If only IPv4
$String0 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$AdaptorInfo[0][3] = ""
Endif
If UBound($objItem.IPAddress) = 2 then                    ; If Both IPV4 and IPV6
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][2] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][3] = $objItem.IPAddress[$String1]
Endif
If UBound($objItem.IPAddress) = 3 then                    ; If Both IPV4 and IPV6
$String00 = UBound($objItem.IPAddress) -3
$AdaptorInfo[0][2] = $objItem.IPAddress[$String00]
$String0 = UBound($objItem.IPAddress) -2
$AdaptorInfo[0][3] = $objItem.IPAddress[$String0]
$String1 = UBound($objItem.IPAddress) -1
$AdaptorInfo[0][19] = $objItem.IPAddress[$String1]
Endif
; ...........................................
; ...........................................
If UBound($objItem.IPSubnet) = 0 then
$AdaptorInfo[0][4] = ""
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 1 then                    ; If Subnet
$String0 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$AdaptorInfo[0][5] = ""
Endif
If UBound($objItem.IPSubnet) = 2 then                    ; If more than one Subnet
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String1]
Endif
If UBound($objItem.IPSubnet) = 3 then                    ; If more than one Subnet
$String00 = UBound($objItem.IPSubnet) -3
$AdaptorInfo[0][4] = $objItem.IPSubnet[$String00]
$String0 = UBound($objItem.IPSubnet) -2
$AdaptorInfo[0][5] = $objItem.IPSubnet[$String0]
$String1 = UBound($objItem.IPSubnet) -1
$AdaptorInfo[0][20] = $objItem.IPSubnet[$String1]
Endif
;$AdaptorInfo[0][4] = $objItem.IPSubnet[0]
;$AdaptorInfo[0][5] = $objItem.IPSubnet[1]
; ...........................................
; ...........................................
If UBound($objItem.DefaultIPGateway) = 0 then
$AdaptorInfo[0][6] = ""
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 1 then                    ; Get the Default Gateway
$String0 = UBound($objItem.DefaultIPGateway) - 1
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$AdaptorInfo[0][16] = ""
Endif
If UBound($objItem.DefaultIPGateway) = 2 then                     ; If more than one Gateway
$String0 = UBound($objItem.DefaultIPGateway) -2
$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[$String0]
$String1 = UBound($objItem.DefaultIPGateway) -1
$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[$String1]
Endif
;$AdaptorInfo[0][6] = $objItem.DefaultIPGateway[0]
;$AdaptorInfo[0][16] = $objItem.DefaultIPGateway[1]
; ...........................................
; ...........................................
;ConsoleWrite("DEBUG0: " & UBound($objItem.DNSServerSearchOrder) & @CRLF)
If UBound($objItem.DNSServerSearchOrder) = 0 then
$AdaptorInfo[0][7] = ""
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 1 then                    ; If one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$AdaptorInfo[0][8] = ""
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 2 then                    ; If more than one DNS
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][17] = ""
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 3 then                    ; If more than one DNS
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String1]
$AdaptorInfo[0][18] = ""
Endif
If UBound($objItem.DNSServerSearchOrder) = 4 then                    ; If more than one DNS
$String000 = UBound($objItem.DNSServerSearchOrder) -4
$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[$String000]
$String00 = UBound($objItem.DNSServerSearchOrder) -3
$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[$String00]
$String0 = UBound($objItem.DNSServerSearchOrder) -2
$AdaptorInfo[0][17] = $objItem.DNSServerSearchOrder[$String0]
$String1 = UBound($objItem.DNSServerSearchOrder) -1
$AdaptorInfo[0][18] = $objItem.DNSServerSearchOrder[$String1]
Endif
;$AdaptorInfo[0][7] = $objItem.DNSServerSearchOrder[0]
;$AdaptorInfo[0][8] = $objItem.DNSServerSearchOrder[1]
; ...........................................
; ...........................................
$AdaptorInfo[0][9] = $objItem.MACAddress
$AdaptorInfo[0][13] = $objItem.DHCPLeaseExpires
; ...........................................
Next
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "WARNING:WINDOWS NIC INFO NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error or not true" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
EndIf

; .................................................. ADD ON INFO
$AdaptorInfo[0][10] = @LogonDomain
$AdaptorInfo[0][11] = @LogonServer
$AdaptorInfo[0][14] = @LogonDNSDomain
$AdaptorInfo[0][15] = @ComputerName
; ..................................................
; ---------------------------------------------
;  DISPLAY THE NIC INFO
; ---------------------------------------------
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite("NETWORK ADAPTOR INFORMATION" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite( $SelectedAdapters[0][7] & @CRLF)
If $SelectedAdapters[0][23] = 0 then
ConsoleWrite("NIC Status: Disabled" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 7 then
ConsoleWrite("NIC Status: Enabled no Connection" & @CRLF)
Endif
If $SelectedAdapters[0][23] = 2 then
ConsoleWrite("NIC Status: Connected ok" & @CRLF)
Endif
ConsoleWrite("NIC Connected: " & $SelectedAdapters[0][24] & @CRLF)
ConsoleWrite("DHCP Enabled: " & $AdaptorInfo[0][0] & @CRLF)
ConsoleWrite("DHCP Lease Ex: " & $AdaptorInfo[0][13] & @CRLF)
ConsoleWrite("DHCP Server: " & $AdaptorInfo[0][1] & @CRLF)
ConsoleWrite("IPV4 Address1: " & $AdaptorInfo[0][2] & @CRLF)
ConsoleWrite("IPV6 Address1: " & $AdaptorInfo[0][3] & @CRLF)
ConsoleWrite("IPV6 Address2: " & $AdaptorInfo[0][19] & @CRLF)
ConsoleWrite("Subnet IPv4: " & $AdaptorInfo[0][4] & @CRLF)
ConsoleWrite("Subnet Prefix IPv4: " & $AdaptorInfo[0][5] & @CRLF)
ConsoleWrite("Subnet Prefix IPv6: " & $AdaptorInfo[0][5] & @CRLF)
Local $aTestedDNSIpv4 = StringRegExp($AdaptorInfo[0][6], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv4 = 1 Then
ConsoleWrite("Gateway IPv4: " & $AdaptorInfo[0][6] & @CRLF)
Else
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][6] & @CRLF)
Endif
Local $aTestedDNSIpv6 = StringRegExp($AdaptorInfo[0][16], "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)
If $aTestedDNSIpv6 = 0 and NOT $AdaptorInfo[0][16] = "" Then
ConsoleWrite("Gateway IPv6: " & $AdaptorInfo[0][16] & @CRLF)
Endif
ConsoleWrite("DNS Primary IPv4: " & $AdaptorInfo[0][7] & @CRLF)
ConsoleWrite("DNS Secondry IPv4: " & $AdaptorInfo[0][8] & @CRLF)
; .............................................................
If $AdaptorInfo[0][17] = "" or $AdaptorInfo[0][18] = "" Then
Local $sNameServer = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\Interfaces\" & $SelectedAdapters[0][10] , "NameServer")
Local $aDNSIPv6array = _StringExplode($sNameServer, ",", 0)
;;_ArrayDisplay($aDNSIPv6array, "DEBUG:")
If UBound($aDNSIPv6array) = 1 then
$AdaptorInfo[0][17] = $aDNSIPv6array[UBound($aDNSIPv6array) -1]
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
Endif
If UBound($aDNSIPv6array) = 2 then
$AdaptorInfo[0][17] = $aDNSIPv6array[UBound($aDNSIPv6array) -2]
ConsoleWrite("DNS Primary IPv6: " & $AdaptorInfo[0][17] & @CRLF)
$AdaptorInfo[0][18] = $aDNSIPv6array[UBound($aDNSIPv6array) -1]
ConsoleWrite("DNS Secondry IPv6: " & $AdaptorInfo[0][18] & @CRLF)
Endif
Endif
; .............................................................
ConsoleWrite("MAC Address: " & $AdaptorInfo[0][9] & @CRLF)
ConsoleWrite("Logon Domain: " & $AdaptorInfo[0][10] & @CRLF)
ConsoleWrite("Logon Server: " & $AdaptorInfo[0][11] & @CRLF)
ConsoleWrite("DNS Server: " & $AdaptorInfo[0][14] & @CRLF)
ConsoleWrite("Computer Name: " & $AdaptorInfo[0][15] & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
return
; ..................................................
; AVALIBLE MS INFO
;  string   Caption;
;  string   Description;
;  string   SettingID;
;  boolean  ArpAlwaysSourceRoute;
;  boolean  ArpUseEtherSNAP;
;  string   DatabasePath;
;  boolean  DeadGWDetectEnabled;
;  string   DefaultIPGateway[];
;  uint8    DefaultTOS;
;  uint8    DefaultTTL;
;  boolean  DHCPEnabled;
;  datetime DHCPLeaseExpires;
;  datetime DHCPLeaseObtained;
;  string   DHCPServer;
;  string   DNSDomain;
;  string   DNSDomainSuffixSearchOrder[];
;  boolean  DNSEnabledForWINSResolution;
;  string   DNSHostName;
;  string   DNSServerSearchOrder[];
;  boolean  DomainDNSRegistrationEnabled;
;  uint32   ForwardBufferMemory;
;  boolean  FullDNSRegistrationEnabled;
;  uint16   GatewayCostMetric[];
;  uint8    IGMPLevel;
;  uint32   Index;
;  uint32   InterfaceIndex;
;  string   IPAddress[];
;  uint32   IPConnectionMetric;
;  boolean  IPEnabled;
;  boolean  IPFilterSecurityEnabled;
;  boolean  IPPortSecurityEnabled;
;  string   IPSecPermitIPProtocols[];
;  string   IPSecPermitTCPPorts[];
;  string   IPSecPermitUDPPorts[];
;  string   IPSubnet[];
;  boolean  IPUseZeroBroadcast;
;  string   IPXAddress;
;  boolean  IPXEnabled;
;  uint32   IPXFrameType[];
;  uint32   IPXMediaType;
;  string   IPXNetworkNumber[];
;  string   IPXVirtualNetNumber;
;  uint32   KeepAliveInterval;
;  uint32   KeepAliveTime;
;  string   MACAddress;
;  uint32   MTU;
;  uint32   NumForwardPackets;
;  boolean  PMTUBHDetectEnabled;
;  boolean  PMTUDiscoveryEnabled;
;  string   ServiceName;
;  uint32   TcpipNetbiosOptions;
;  uint32   TcpMaxConnectRetransmissions;
;  uint32   TcpMaxDataRetransmissions;
;  uint32   TcpNumConnections;
;  boolean  TcpUseRFC1122UrgentPointer;
;  uint16   TcpWindowSize;
;  boolean  WINSEnableLMHostsLookup;
;  string   WINSHostLookupFile;
;  string   WINSPrimaryServer;
;  string   WINSScopeID;
;  string   WINSSecondaryServer;
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------
; --------------------------
; GET THE WMI SELECT ADDAPTORS INFO
; --------------------------
Func _GetSelectedNIC()
Local $o_WMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" )
;Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Local Area Connection'", "WQL", 0x30 )
Local $query = $o_WMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='Wireless Network Connection'", "WQL", 0x30 )
; ..................................................
If @error Then
ConsoleWrite("" & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC get Error" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite( "************************************************************" & @CRLF)
Return
EndIf
; ..................................................
For $objItem In $query
If IsObj($query) Then
;$SelectedAdapters[0][0] = $objItem.AdapterTypeID
;$SelectedAdapters[0][1] = $objItem.AutoSense
;$SelectedAdapters[0][2] = $objItem.Availability
;$SelectedAdapters[0][3] = $objItem.Caption
;$SelectedAdapters[0][4] = $objItem.ConfigManagerErrorCode
;$SelectedAdapters[0][5] = $objItem.ConfigManagerUserConfig
;;;$SelectedAdapters[0][6] = $objItem.reationClassName
$SelectedAdapters[0][7] = $objItem.Description
;$SelectedAdapters[0][8] = $objItem.ErrorCleared
;$SelectedAdapters[0][9] = $objItem.ErrorDescription
$SelectedAdapters[0][10] = $objItem.GUID
$SelectedAdapters[0][11] = $objItem.Index
;$SelectedAdapters[0][12] = $objItem.InstallDate
;$SelectedAdapters[0][13] = $objItem.Installed
;$SelectedAdapters[0][14] = $objItem.InterfaceIndex
;$SelectedAdapters[0][15] = $objItem.LastErrorCode
;$SelectedAdapters[0][16] = $objItem.MACAddress
;$SelectedAdapters[0][17] = $objItem.Manufacturer
;$SelectedAdapters[0][18] = $objItem.MaxNumberControlled
;$SelectedAdapters[0][19] = $objItem.MaxSpeed
;$SelectedAdapters[0][21] = $objItem.Name
$SelectedAdapters[0][22] = $objItem.NetConnectionID
$SelectedAdapters[0][23] = $objItem.NetConnectionStatus
$SelectedAdapters[0][24] = $objItem.NetEnabled
;ConsoleWrite("DEBUG2: " & UBound($objItem.NetworkAddresses) & @CRLF)
;;;$SelectedAdapters[0][25] = $objItem.NetworkAddresses[0]
;ConsoleWrite("DEBUG3: " & UBound($objItem.PermanentAddress) & @CRLF)
;$SelectedAdapters[0][26] = $objItem.PermanentAddress
;$SelectedAdapters[0][27] = $objItem.PhysicalAdapter
;$SelectedAdapters[0][28] = $objItem.PNPDeviceID
;;;$SelectedAdapters[0][29] = $objItem.PowerManagementCapabilities[0]
;$SelectedAdapters[0][30] = $objItem.PowerManagementSupported
;$SelectedAdapters[0][31] = $objItem.ProductName
;$SelectedAdapters[0][32] = $objItem.ServiceName
;$SelectedAdapters[0][33] = $objItem.Speed
;$SelectedAdapters[0][34] = $objItem.Status
;$SelectedAdapters[0][35] = $objItem.StatusInfo
;$SelectedAdapters[0][36] = $objItem.SystemCreationClassName
;;;$SelectedAdapters[0][37] = $objItem.SystemName
;;;$SelectedAdapters[0][38] = $objItem.TimeOfLastReset
;ConsoleWrite("DEBUG2: " & ubound($objItem.NetworkAddresses) & @CRLF)
;_ArrayDisplay($SelectedAdapters, "DEBUG:")
; ..................................................
Else
ConsoleWrite("" & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("WARNING:SELECTED NIC NOT FOUND" & @CRLF)
ConsoleWrite("Not completed error" & @CRLF)
ConsoleWrite(" " & @CRLF)
ConsoleWrite("************************************************************" & @CRLF)
Return
Endif
; ..................................................
Next
; RETURN JUST THE INDEX OF THE SELECTED ADAPTOR USED TO SEARCH THE INFO OF CARD
Return $SelectedAdapters[0][11]
; ..................................................
EndFunc

;------------------------------------------------------------------------------------------------------------

 

Edited by Dwalfware
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...