Set colAdapters = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
n = 1 WScript.Echo
For Each objAdapter in colAdapters WScript.Echo "Network Adapter " & n WScript.Echo "=================" WScript.Echo " Description: " & objAdapter.Description
If Not IsNull(objAdapter.IPAddress) Then For i = 0 To UBound(objAdapter.IPAddress) WScript.Echo " IP address: " & objAdapter.IPAddress(i) Next End If
If Not IsNull(objAdapter.IPSubnet) Then For i = 0 To UBound(objAdapter.IPSubnet) WScript.Echo " Subnet: " & objAdapter.IPSubnet(i) Next End If
If Not IsNull(objAdapter.DefaultIPGateway) Then For i = 0 To UBound(objAdapter.DefaultIPGateway) WScript.Echo " Default gateway: " & _ objAdapter.DefaultIPGateway(i) Next End If
WScript.Echo WScript.Echo " DNS" WScript.Echo " ---" WScript.Echo " DNS servers in search order:"
If Not IsNull(objAdapter.DNSServerSearchOrder) Then For i = 0 To UBound(objAdapter.DNSServerSearchOrder) WScript.Echo " " & objAdapter.DNSServerSearchOrder(i) Next End If
WScript.Echo " DNS domain: " & objAdapter.DNSDomain
If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder) WScript.Echo " DNS suffix search list: " & _ objAdapter.DNSDomainSuffixSearchOrder(i) Next End If
If Not IsNull(objAdapter.DHCPLeaseObtained) Then utcLeaseObtained = objAdapter.DHCPLeaseObtained strLeaseObtained = WMIDateStringToDate(utcLeaseObtained) Else strLeaseObtained = "" End If WScript.Echo " DHCP lease obtained: " & strLeaseObtained
If Not IsNull(objAdapter.DHCPLeaseExpires) Then utcLeaseExpires = objAdapter.DHCPLeaseExpires strLeaseExpires = WMIDateStringToDate(utcLeaseExpires) Else strLeaseExpires = "" End If WScript.Echo " DHCP lease expires: " & strLeaseExpires