One of my computers has a duplicate IP address conflict. Can Hyena export ALL the MAC addresses for the workstations on my network? Thanks.
Announcement
Collapse
No announcement yet.
Exporting MAC addresses
Collapse
X
-
Re: Exporting MAC addresses
WMI will get you the MAC addresses for all Network Adapters on a machine.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
Wscript.Echo "AdapterType: " & objItem.AdapterType
Wscript.Echo "AdapterTypeId: " & objItem.AdapterTypeId
Wscript.Echo "AutoSense: " & objItem.AutoSense
Wscript.Echo "Availability: " & objItem.Availability
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
Wscript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
Wscript.Echo "CreationClassName: " & objItem.CreationClassName
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "ErrorCleared: " & objItem.ErrorCleared
Wscript.Echo "ErrorDescription: " & objItem.ErrorDescription
Wscript.Echo "Index: " & objItem.Index
Wscript.Echo "InstallDate: " & objItem.InstallDate
Wscript.Echo "Installed: " & objItem.Installed
Wscript.Echo "LastErrorCode: " & objItem.LastErrorCode
Wscript.Echo "MACAddress: " & objItem.MACAddress
Wscript.Echo "Manufacturer: " & objItem.Manufacturer
Wscript.Echo "MaxNumberControlled: " & objItem.MaxNumberControlled
Wscript.Echo "MaxSpeed: " & objItem.MaxSpeed
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "NetConnectionID: " & objItem.NetConnectionID
Wscript.Echo "NetConnectionStatus: " & objItem.NetConnectionStatus
Wscript.Echo "NetworkAddresses: " & objItem.NetworkAddresses
Wscript.Echo "PermanentAddress: " & objItem.PermanentAddress
Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
Wscript.Echo "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities
Wscript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
Wscript.Echo "ProductName: " & objItem.ProductName
Wscript.Echo "ServiceName: " & objItem.ServiceName
Wscript.Echo "Speed: " & objItem.Speed
Wscript.Echo "Status: " & objItem.Status
Wscript.Echo "StatusInfo: " & objItem.StatusInfo
Wscript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
Wscript.Echo "SystemName: " & objItem.SystemName
Wscript.Echo "TimeOfLastReset: " & objItem.TimeOfLastReset
Next
Trim this up to remove the items you don't need, and if you only want actual NICs, run an If/Then statement on the AdapterType.
Hope this helps.
Joel
Comment
-
Re: Exporting MAC addresses
You can also use GetMac from the 2000 Server Resource Kit.
You can run this against the entire domain...(getmac \\servername).
You can export your servernames to Excel, add the Getmac, and concatenate the columns together. Then copy the commands into notepad and run it as a batch file.
[This message has been edited by Braunyaur (edited 10-29-2003).]
Comment
-
Re: Exporting MAC addresses
What I was really looking to do was find a script or program that would enumerate ALL the MAC addresses of all the workstations on my subnet. I ended up using some batch files from John Saville (Window Magazine, Dec. 14, 1999, "How Can I Get a List of IP addresses on a Network?"). He basically creates a batch file to ping every computer on the subnet runs an arp against it to determine the MAC address, and then parses the results using findstr. I can supply more detailed info if necessary. Thanks for replying!
Comment
-
Re: Exporting MAC addresses
Looping the script I provided will do what you want.
You just need to extract the computers that are online, like so:
' run Net View to extract computers that are online. This cuts down on the time the script runs
strRunPath = "cmd /c net view /domain:" & strDomain & " > " & strTempFile
WshShell.Run(strRunPath)
WScript.Sleep(1000) ' pause to allow the Run command to complete
' open the temp file for reading
Set objTempFile = fso.OpenTextFile(strTempFile, 1, false)
'read until the end of the file
While Not objTempFile.AtEndOfStream
strTempLine = objTempFile.ReadLine
'MsgBox Left(strTempLine,2)
If Left(strTempLine,2) = "\" Then
strComputer = Mid(Trim(Left(strTempLine,23)),3) ' trim the line and extract the computer name
Obviously, you'd insert the WMI code provided earlier and then close the IF and WHILE loops.
Hope this helps!
Joel
Comment
Comment