WMIC - how to access array

Viewed 82

I'm trying to get data from wmic (I have to detect the interface ID of the one having a specific primary DNS)

The line I'm looking for is:

ArpAlwaysSourceRoute  ArpUseEtherSNAP  Caption                                          DatabasePath                       DeadGWDetectEnabled  DefaultIPGateway  DefaultTOS  DefaultTTL  Description                           DHCPEnabled  DHCPLeaseExpires           DHCPLeaseObtained          DHCPServer    DNSDomain  DNSDomainSuffixSearchOrder  DNSEnabledForWINSResolution  DNSHostName  DNSServerSearchOrder    DomainDNSRegistrationEnabled  ForwardBufferMemory  FullDNSRegistrationEnabled  GatewayCostMetric  IGMPLevel  Index  InterfaceIndex  IPAddress                                         IPConnectionMetric  IPEnabled  IPFilterSecurityEnabled  IPPortSecurityEnabled  IPSecPermitIPProtocols  IPSecPermitTCPPorts  IPSecPermitUDPPorts  IPSubnet                   IPUseZeroBroadcast  IPXAddress  IPXEnabled  IPXFrameType  IPXMediaType  IPXNetworkNumber  IPXVirtualNetNumber  KeepAliveInterval  KeepAliveTime  MACAddress         MTU  NumForwardPackets  PMTUBHDetectEnabled  PMTUDiscoveryEnabled  ServiceName  SettingID                               TcpipNetbiosOptions  TcpMaxConnectRetransmissions  TcpMaxDataRetransmissions  TcpNumConnections  TcpUseRFC1122UrgentPointer  TcpWindowSize  WINSEnableLMHostsLookup  WINSHostLookupFile  WINSPrimaryServer  WINSScopeID  WINSSecondaryServer  

                                       [00000005] TP-LINK Gigabit Ethernet USB Adapter  %SystemRoot%\System32\drivers\etc                                                                 TP-LINK Gigabit Ethernet USB Adapter  FALSE                                                                                       {}                          FALSE                        BACCHINB     {"8.8.8.8", "8.8.4.4"}  FALSE                                              TRUE                                                      5      17              {"192.168.200.210", "fe80::c156:9171:8b58:ac61"}  25                  TRUE       FALSE                                           {}                      {}                   {}                   {"255.255.255.0", "64"}                                                                                                                                                     50:3E:AA:D3:94:F5                                                                     rtux64w10    {CD6DF33E-637E-446A-B589-7A9F1FF9F86D}  0                                                                                                                                           TRUE  

My query would be like WMIC NICCONFIG where DNSServerSearchOrder[0]=8.8.8.8 get Index,description

Now I get Invalid Query.

When I expect something like: TP-LINK Gigabit Ethernet USB Adapter 5

1 Answers

You can try something like that :

WMIC nicconfig where (IPEnabled=TRUE and DHCPEnabled=False) get Index,description

EDIT : In Powershell

Get-WmiObject Win32_NetworkAdapterConfiguration | ForEach-Object {if ($_.DNSServerSearchOrder -EQ '8.8.8.8'){Write-Host "$($_.index),$($_.Description)"}}
Related