Jump to content

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 :(

 

Share this post


Link to post
Share on other sites

@Dwalfware

Without seeing your entire code, seems a bit tricky :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

3270 lines of code .... lol   :D

I would need to do a bit more work before I can reveal all that code.

 

 

 

Edited by Dwalfware

Share this post


Link to post
Share on other sites

@Dwalfware

We can't see the content of both $cboAdapters nor _GetSelectedNIC(), so, we can't ain't assist you :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
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

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

 

Share this post


Link to post
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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

@Dwalfware

Could you please post the source string you are trying to explode, and the result you are trying to achieve? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
10 hours ago, FrancescoDiMuro said:

@Dwalfware

Could you please post the source string you are trying to explode, and the result you are trying to achieve? :)

Its all good now, The result was was made. ;) Its all in the last code. SOLVED 

Cheers 

D

Share this post


Link to post
Share on other sites

@Dwalfware

There is no sample Alternative IP, nor an expected result, but, happy that you solved :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

  • Similar Content

    • By jresine
      Hello, is it possible to know via a script or command, to have the percentage of disk usage of a process? thank you in advance.
      ps: see image

    • By Dwalfware
      Does anyone know how to find IPv6 expression. 
      I have Ipv4 but with IPv6 the address is never strait, some times you have 5 ":"  some times you have 7?
      Local $aISITIPv4 = StringRegExp("192.168.0.1", "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0) any ideas how to code for below? Lost   Point in right direction or tip please. Begging 
      2001:4860:4860::8888 2001:4860:4860::8844 2620:0:ccc::2 2620:0:ccd::2 2a02:6b8::feed:0ff 2a02:6b8:0:1::feed:0ff 2001:67c:28a4:: 2002:d596:2a92:1:71:53:: 2001:470:6c:521::2 2001:470:6d:521::1 2001:1608:10:25::1c04:b12f 2001:1608:10:25::9249:d69b 2001:910:800::12 2001:910:800::40 2606:4700:4700::1111 2606:4700:4700::1001 2610:a1:1018::1 2610:a1:1019::1 2610:a1:1018::5 2610:a1:1019::5 2a00:5a60::ad1:0ff 2a00:5a60::ad2:0ff 2a02:6b8::feed:a11 2a02:6b8:0:1::feed:a11 2a0d:2a00:1:: 2a0d:2a00:2:: 2a0d:2a00:1::1 2a0d:2a00:2::1 2610:a1:1018::3 2610:a1:1019::3 2610:a1:1018::4 2610:a1:1019::4 2a00:5a60::bad1:0ff 2a00:5a60::bad2:0ff 2a02:6b8::feed:bad 2a02:6b8:0:1::feed:bad 2a0d:2a00:1::2 2a0d:2a00:2::2 2610:a1:1018::2 2610:a1:1019::2  
    • By Dwalfware
      Hi Folks
      Can not get my head around this one.
      This function gets the DNS object s
      If you have two DNS entries fine. but if you have only one! Trouble
      $objItem.DNSServerSearchOrder[0] = Primary DNS
      $objItem.DNSServerSearchOrder[1] = Secondry DNS not always there. I need a way to return 0 if not there or the IP if its there.
      Or is there a way to tell how many objects there are in the "[?]"
      I'm terrible at WMI errors, thanks for help in advance.
      Func _GETcurrentNICinfo2() $oErrors = ObjEvent("AutoIt.Error", "Error_Handle") Local $DnsSecondry Local $objWMIService = ObjGet( "winmgmts:\\" & @ComputerName & "\root\CIMV2" ) Local $query = $objWMIService.ExecQuery("SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 ) If @error Then Return 0 If NOT IsObj($query) Then Return 0 Else For $objItem In $query Return $objItem.DNSServerSearchOrder[1] next Endif EndFunc  
    • By leomoon
      Hello,
      I'm having trouble getting information from Win32_Processor:
      https://docs.microsoft.com/en-us/windows/desktop/CIMWin32Prov/win32-processor
      How does this WMI Query work? Let's say I need to query VMMonitorModeExtensions, Level, ProcessorId, and ProcessorType.
      How would this work?
      Thanks.
    • By colombeen
      Hi everyone, I created a function to gather bitlocker information. It can tell you whether or not a drive is protected, which encryption method is being used, ...
      I tried to cover all the details in the function description
       
      The function (and 3 "internal" functions) :
      ; #FUNCTION# ==================================================================================================================== ; Name...........: _BitlockerDriveInfo ; Description ...: Get Bitlocker information for one or multiple drives ; Syntax.........: _BitlockerDriveInfo([$sDrive[, $sComputer = @ComputerName[, $bDebug = False]]]) ; Parameters ....: $sDrive - Optional: The drive. Allowed values are: ; |"" - Get the info for all available drives ; |Letter: - Get the info for the specific drive ; $sComputer - Optional: The computer from which the info should be requested ; $bDebug - Optional: Shows the hex ReturnValue from the WMI methods if set to True ; Return values .: Success - Returns a 2D array with the following information ; |[string] Drive Letter ; |[string] Drive Label ; |[string] Volume Type ; |[bool] Initialized For Protection ; |[string] Protection Status ; |[string] Lock Status ; |[bool] Auto Unlock Enabled ; |[bool] Auto Unlock Key Stored ; |[string] Conversion Status ; |[string] Encryption Method ; |[int] Encryption Percentage ; |[string] Wiping Status ; |[int] Wiping Percentage ; |[array] Key Protectors (Or [string] "None" if the drive isn't protected) ; Failure - 0, sets @error to: ; |1 - There was an issue retrieving the COM object. @extended returns error code from ObjGet ; |2 - The specified drive in $Drive doesn't exist ; |3 - There was an issue running the WMI query ; Author ........: colombeen ; Modified.......: ; Remarks .......: Requires to be run with admin elevation. Windows Vista or newer! ; A BIG THANKS to everyone from the community who contributed! ; Related .......: ; Link ..........: ; Example .......: #include <Array.au3> ; $Header = "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|" & _ ; "Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption " & _ ; "Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors" ; _ArrayDisplay(_BitlockerDriveInfo(), "Bitlocker Drive Info", "", 64, Default, $Header) ; =============================================================================================================================== Func _BitlockerDriveInfo($sDrive = "", $sComputer = @ComputerName, $bDebug = False) Local $aConversionStatusMsg[7] = ["Unknown", "Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"] Local $aEncryptionMethodMsg[9] = ["Unknown", "None", "AES_128_WITH_DIFFUSER", "AES_256_WITH_DIFFUSER", "AES_128", "AES_256", "HARDWARE_ENCRYPTION", "XTS_AES_128", "XTS_AES_256"] Local $aKeyProtectorTypeMsg[11] = ["Unknown or other protector type", "Trusted Platform Module (TPM)", "External key", "Numerical password", "TPM And PIN", "TPM And Startup Key", "TPM And PIN And Startup Key", "Public Key", "Passphrase", "TPM Certificate", "CryptoAPI Next Generation (CNG) Protector"] Local $aLockStatusMsg[3] = ["Unknown", "Unlocked", "Locked"] Local $aProtectionStatusMsg[3] = ["Unprotected", "Protected", "Unknown"] Local $aVolumeTypeMsg[3] = ["Operating System Volume", "Fixed Data Volume", "Portable Data Volume"] Local $aWipingStatusMsg[5] = ["Unknown", "Free Space Not Wiped", "Free Space Wiped", "Free Space Wiping In Progress", "Free Space Wiping Paused"] Local $iRow = 0 Local $sRunMethod, $objWMIService, $objWMIQuery, $sDriveFilter, $iProtectionStatus, $iLockStatus, $bIsAutoUnlockEnabled, $bIsAutoUnlockKeyStored, $iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage, $iEncryptionMethod, $aVolumeKeyProtectorID, $aVolumeKeyProtectors, $iKeyProtectorType $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption") If @error Then Return SetError(1, @error, 0) If $sDrive <> "" Then Local $iDriveType = _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $sDrive & "'", Default, $sComputer) If @error Or ($iDriveType <> 2 And $iDriveType <> 3) Then Return SetError(2, 0, 0) $sDriveFilter = " WHERE DriveLetter='" & $sDrive & "'" EndIf $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume" & $sDriveFilter, "WQL", 0) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) Local $aResult[$objWMIQuery.count][14] For $objDrive In $objWMIQuery If $bDebug Then ConsoleWrite(@CRLF & "+> " & $objDrive.DriveLetter & @CRLF) If _WMIMethodExists($objDrive, "GetConversionStatus") Then $sRunMethod = $objDrive.GetConversionStatus($iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage) If $bDebug Then ConsoleWrite("!> GetConversionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iConversionStatus = -1 $iWipingStatus = -1 $iEncryptionPercentage = 0 $iWipingPercentage = 0 EndIf If _WMIMethodExists($objDrive, "GetEncryptionMethod") Then $sRunMethod = $objDrive.GetEncryptionMethod($iEncryptionMethod) If $bDebug Then ConsoleWrite("!> GetEncryptionMethod 0x" & Hex($sRunMethod) & @CRLF) Else $iEncryptionMethod = 0 EndIf If _WMIMethodExists($objDrive, "GetKeyProtectors") Then $sRunMethod = $objDrive.GetKeyProtectors("0", $aVolumeKeyProtectorID) If $bDebug Then ConsoleWrite("!> GetKeyProtectors 0x" & Hex($sRunMethod) & @CRLF) Else $aVolumeKeyProtectorID = 0 EndIf If _WMIMethodExists($objDrive, "GetLockStatus") Then $sRunMethod = $objDrive.GetLockStatus($iLockStatus) If $bDebug Then ConsoleWrite("!> GetLockStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iLockStatus = -1 EndIf If _WMIMethodExists($objDrive, "GetProtectionStatus") Then $sRunMethod = $objDrive.GetProtectionStatus($iProtectionStatus) If $bDebug Then ConsoleWrite("!> GetProtectionStatus 0x" & Hex($sRunMethod) & @CRLF) Else $iProtectionStatus = 2 EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockEnabled") Then $sRunMethod = $objDrive.IsAutoUnlockEnabled($bIsAutoUnlockEnabled) If $bDebug Then ConsoleWrite("!> IsAutoUnlockEnabled 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockEnabled = "Unknown" EndIf If _WMIMethodExists($objDrive, "IsAutoUnlockKeyStored") Then $sRunMethod = $objDrive.IsAutoUnlockKeyStored($bIsAutoUnlockKeyStored) If $bDebug Then ConsoleWrite("!> IsAutoUnlockKeyStored 0x" & Hex($sRunMethod) & @CRLF) Else $bIsAutoUnlockKeyStored = "Unknown" EndIf If IsArray($aVolumeKeyProtectorID) And UBound($aVolumeKeyProtectorID) > 0 Then Dim $aVolumeKeyProtectors[UBound($aVolumeKeyProtectorID)][2] For $i = 0 To UBound($aVolumeKeyProtectorID) - 1 $aVolumeKeyProtectors[$i][0] = $aVolumeKeyProtectorID[$i] If _WMIMethodExists($objDrive, "GetKeyProtectorType") Then If $objDrive.GetKeyProtectorType($aVolumeKeyProtectorID[$i], $iKeyProtectorType) = 0 Then $aVolumeKeyProtectors[$i][1]= $aKeyProtectorTypeMsg[$iKeyProtectorType] Else $aVolumeKeyProtectors[$i][1]= "Unknown" EndIf Else $aVolumeKeyProtectors[$i][1] = "Unknown" EndIf Next Else $aVolumeKeyProtectors = "None" EndIf ; DriveLetter $aResult[$iRow][0] = $objDrive.DriveLetter ; DriveLabel $aResult[$iRow][1] = _WMIPropertyValue("VolumeName", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) ; VolumeType If _WMIPropertyExists($objDrive, "VolumeType") Then $aResult[$iRow][2] = $aVolumeTypeMsg[$objDrive.VolumeType] Else If $objDrive.DriveLetter = _WMIPropertyValue("SystemDrive", "Win32_OperatingSystem", "", Default, $sComputer) Then $aResult[$iRow][2]= $aVolumeTypeMsg[0] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 3 Then $aResult[$iRow][2]= $aVolumeTypeMsg[1] ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 2 Then $aResult[$iRow][2]= $aVolumeTypeMsg[2] Else $aResult[$iRow][2]= "Unknown" EndIf EndIf ; IsVolumeInitializedForProtection If _WMIPropertyExists($objDrive, "IsVolumeInitializedForProtection") Then $aResult[$iRow][3] = $objDrive.IsVolumeInitializedForProtection Else $aResult[$iRow][3] = "Unkown" EndIf ; ProtectionStatus $aResult[$iRow][4] = $aProtectionStatusMsg[$iProtectionStatus] ; LockStatus $aResult[$iRow][5] = $aLockStatusMsg[$iLockStatus + 1] ; IsAutoUnlockEnabled $aResult[$iRow][6] = $bIsAutoUnlockEnabled ; IsAutoUnlockEnabled $aResult[$iRow][7] = $bIsAutoUnlockKeyStored ; ConversionStatus $aResult[$iRow][8] = $aConversionStatusMsg[$iConversionStatus + 1] ; EncryptionMethod $aResult[$iRow][9] = $aEncryptionMethodMsg[$iEncryptionMethod + 1] ; EncryptionPercentage $aResult[$iRow][10] = $iEncryptionPercentage ; WipingStatus $aResult[$iRow][11] = $aWipingStatusMsg[$iWipingStatus + 1] ; WipingPercentage $aResult[$iRow][12] = $iWipingPercentage ; KeyProtectors $aResult[$iRow][13] = $aVolumeKeyProtectors $iRow += 1 Next _ArraySort($aResult) Return $aResult EndFunc ;==>_BitlockerDriveInfo Func _WMIPropertyExists($Object, $Property) If Not IsObj($Object) Then Return False For $sProperty In $Object.Properties_ If $sProperty.Name = $Property Then Return True Next Return False EndFunc ;==>_WMIPropertyExists Func _WMIMethodExists($Object, $Method) If Not IsObj($Object) Then Return False For $sMethod In $Object.Methods_ If $sMethod.Name = $Method Then Return True Next Return False EndFunc ;==>_WMIMethodExists Func _WMIPropertyValue($sProperty = "", $sClass = "", $sFilter = "", $sNamespace = Default, $sComputer = @ComputerName) Local $objWMIService, $objWMIQuery If $sClass = "" Or $sProperty = "" Then Return SetError(1, 0, 0) If $sFilter <> "" Then $sFilter = " " & $sFilter If $sNamespace = Default Then $sNamespace = "\root\CIMV2" $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & $sNamespace) If @error Then Return SetError(2, @error, 0) $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM " & $sClass & $sFilter, "WQL", 0x30) If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0) For $objItem In $objWMIQuery For $Property In $objItem.Properties_ If $Property.Name = $sProperty Then Return $Property.Value EndIf Next Next Return SetError(4, 0, 0) EndFunc ;==>_WMIPropertyValue  
      Example 1:
      #RequireAdmin #include <array.au3> ; Get information on all available drives Global $test = _BitlockerDriveInfo() If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then _ArrayDisplay($test, "Bitlocker Drive Info", "", 64, Default, "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors") ; Display the Key Protectors for the first record If IsArray($test[0][13]) Then _ArrayDisplay($test[0][13]) EndIf Example 2:
      #RequireAdmin #include <array.au3> ; Get information on the C-drive of the current computer + show extra information in the console Global $test = _BitlockerDriveInfo("C:", @ComputerName, True) If @error Then ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF) ElseIf IsArray($test) Then ConsoleWrite("Bitlocker information on the " & $test[0][0] & " drive" & @CRLF) ConsoleWrite("Protection Status: " & $test[0][4] & @CRLF) EndIf  
      Screenshot for the first example:

       
      Suggestions? Bugs?
      Just let me know
       
      TODO:
      ???  
      Version 1.0:
      Initial release Version 1.1:
      Fixed: Drive Label will not work when you request the information from a remote system (currently using DriveGetLabel) Fixed: The current fix for the missing VolumeType property in some Windows versions will only work locally Added: New internal function (_WMIPropertyValue()) Version 1.2:
      Fixed: The drive exists & drive type check only worked locally when a drive was specified in $sDrive
×
×
  • Create New...