0% found this document useful (0 votes)
68 views1 page

Script para Coletar Remotamente Hostname, IP e MAC Address

This script uses Windows Management Instrumentation (WMI) to retrieve the MAC addresses of computers on a network. It opens a text file containing IP addresses, passes each IP to a subroutine to get the hostname, IP address and MAC address using WMI, and displays the results. The subroutine uses WMI to query the Win32_NetworkAdapterConfiguration class for enabled network adapters, and returns the hostname, first IP address, and MAC address for each one.

Uploaded by

Rosemir Moreira
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

Script para Coletar Remotamente Hostname, IP e MAC Address

This script uses Windows Management Instrumentation (WMI) to retrieve the MAC addresses of computers on a network. It opens a text file containing IP addresses, passes each IP to a subroutine to get the hostname, IP address and MAC address using WMI, and displays the results. The subroutine uses WMI to query the Win32_NetworkAdapterConfiguration class for enabled network adapters, and returns the hostname, first IP address, and MAC address for each one.

Uploaded by

Rosemir Moreira
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

On Error Resume Next Dim fso Dim tst Dim objTS Dim strMachineName Set fso = createObject("Scripting.

FileSystemObject") 'here is where you will provide the ip list to get the mac information Set tst = fso.OpenTextFile("C:\iprange.txt", 1, false) While Not tst.AtEndOfStream strMachineName = tst.readLine echoMAC strMachineName Wend Sub echoMAC(strComputer) On error resume next If strComputer <> "" Then strInput = True End if Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\ro ot\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem in colItems 'you can use wscript.write, instead of wscript.echo to save the information on a file wscript.echo objItem.dnshostname & ";" & objItem.I PAddress(0) & ";" & objItem.MACAddress Next End Sub

You might also like