Notification

Icon
Error

List IP Configuration Data

Posted: Thursday, November 4, 2021 4:35:06 PM(UTC)
Don

Don

Member Original PosterPosts: 33
0
Like
Run this asset action:

Code:

{actionpath}list_ip_config.vbs {computer}


Here is the content of "list_ip_config.vbs"

Code:

' List IP Configuration Data

strComputer = WScript.Arguments(0)

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
n = 1
strMsg = ""
 
For Each objAdapter in colAdapters
   strMsg = strMsg & "Network Adapter " &  VbCrLf
   strMsg = strMsg & "================="  & VbCrLf
   strMsg = strMsg & "  Description: " & objAdapter.Description  & VbCrLf
 
   strMsg = strMsg & "  Physical (MAC) address: " & objAdapter.MACAddress  & VbCrLf
   strMsg = strMsg & "  Host name:              " & objAdapter.DNSHostName  & VbCrLf
 
   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
         strMsg = strMsg & "  IP address:             " & objAdapter.IPAddress(i)  & VbCrLf
      Next
   End If
 
   If Not IsNull(objAdapter.IPSubnet) Then
      For i = 0 To UBound(objAdapter.IPSubnet)
         strMsg = strMsg & "  Subnet:                 " & objAdapter.IPSubnet(i) & VbCrLf
      Next
   End If
 
   If Not IsNull(objAdapter.DefaultIPGateway) Then
      For i = 0 To UBound(objAdapter.DefaultIPGateway)
         strMsg = strMsg & "  Default gateway:        " & _
             objAdapter.DefaultIPGateway(i) & VbCrLf
      Next
   End If
 
   strMsg = strMsg & "" & VbCrLf
   strMsg = strMsg & "  DNS" & VbCrLf
   strMsg = strMsg & "================="  & VbCrLf
   strMsg = strMsg & "    DNS servers in search order:" & VbCrLf
 
   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
         strMsg = strMsg & "      " & objAdapter.DNSServerSearchOrder(i) & VbCrLf
      Next
   End If
 
   strMsg = strMsg & "    DNS domain: " & objAdapter.DNSDomain & VbCrLf
 
   If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
         strMsg = strMsg & "    DNS suffix search list: " & _
             objAdapter.DNSDomainSuffixSearchOrder(i) & VbCrLf
      Next
   End If
 
   strMsg = strMsg & "" & VbCrLf
   strMsg = strMsg & "  DHCP" & VbCrLf
   strMsg = strMsg & "================="  & VbCrLf
   strMsg = strMsg & "    DHCP enabled:        " & objAdapter.DHCPEnabled & VbCrLf
   strMsg = strMsg & "    DHCP server:         " & objAdapter.DHCPServer & VbCrLf
 
   If Not IsNull(objAdapter.DHCPLeaseObtained) Then
      utcLeaseObtained = objAdapter.DHCPLeaseObtained
      strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
   Else
      strLeaseObtained = ""
   End If
   strMsg = strMsg & "    DHCP lease obtained: " & strLeaseObtained & VbCrLf
 
   If Not IsNull(objAdapter.DHCPLeaseExpires) Then
      utcLeaseExpires = objAdapter.DHCPLeaseExpires
      strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
   Else
      strLeaseExpires = ""
   End If
   strMsg = strMsg & "    DHCP lease expires:  " & strLeaseExpires & VbCrLf
 
   strMsg = strMsg & "" & VbCrLf
   strMsg = strMsg & "  WINS" & VbCrLf
   strMsg = strMsg & "================="  & VbCrLf
   strMsg = strMsg & "    Primary WINS server:   " & objAdapter.WINSPrimaryServer & VbCrLf
   strMsg = strMsg & "    Secondary WINS server: " & objAdapter.WINSSecondaryServer & VbCrLf
   strMsg = strMsg & ""
 
   n = n + 1
 
Next
 
Function WMIDateStringToDate(utcDate)
   WMIDateStringToDate = CDate(Mid(utcDate, 5, 2)  & "/" & _
       Mid(utcDate, 7, 2)  & "/" & _
           Left(utcDate, 4)    & " " & _
               Mid (utcDate, 9, 2) & ":" & _
                   Mid(utcDate, 11, 2) & ":" & _
                      Mid(utcDate, 13, 2))
End Function


 msgbox  strMsg,0,"IP Configuration Data"

Active Discussions

Lansweeper Clearing Thermal State Warning
by  calmed-anodises   Go to last post Go to first unread
Last post: 5/20/2022 6:28:27 PM(UTC)
Lansweeper Quality problems with Lansweeper
by  Hendrik.VE  
Go to last post Go to first unread
Last post: 5/20/2022 3:43:44 PM(UTC)
Lansweeper Bitlocker keys
by  SWResearch   Go to last post Go to first unread
Last post: 5/20/2022 1:34:18 PM(UTC)
Lansweeper Lansweeper Helpdesk instructional webinar
by  Erik.T  
Go to last post Go to first unread
Last post: 5/20/2022 10:40:30 AM(UTC)
Lansweeper Outlook task and calendar
by  ITVTECH   Go to last post Go to first unread
Last post: 5/20/2022 8:26:51 AM(UTC)
Lansweeper SCCM scanning incorrectly reporting last seen results
by  SWResearch  
Go to last post Go to first unread
Last post: 5/20/2022 12:34:52 AM(UTC)
Lansweeper Scanning certificates
by  EagleEyeJoe   Go to last post Go to first unread
Last post: 5/19/2022 7:39:24 PM(UTC)
Lansweeper Lansweeper Cloud Location
by  FrankSc  
Go to last post Go to first unread
Last post: 5/19/2022 7:07:49 PM(UTC)