There are a lot of comercial software packages out there that will do just that. But if you are not willing to pay for a product you can modify this VB script to suite your needs:
Option Explicit
Dim Row, XL, WshShell, FileSystem, RegularExpression, Dummy, TheNVFile, TheLine
Dim Whacks, WhacksFound, WhacksPattern, Flag, HostName, NBTable, PingReport, PingPattern
Dim IPAddress, MACPattern, NamePattern, MACAddress, Matches, TheMatch, Match, NBCommand, TheNBTFile, PCname
Dim IPCommand, TheIPFile, FileName, TheDate, Suggestion, Book
Const ForReading = 1
Row = 2
Set XL = WScript.CreateObject("Excel.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set RegularExpression = New RegExp
Dummy = WshShell.Popup ("Compiling Network Address Inventory. Please Wait...",1,"Network Address Inventory Utility",64)
Call BuildSpreadSheet()
Set TheNVFile = FileSystem.OpenTextFile("C:\Windows\Temp\NetViewList.txt", ForReading, True)
Do While TheNVFile.AtEndOfStream <> True
TheLine = TheNVFile.ReadLine
Whacks = "\\"
WhacksFound = FindPattern(TheLine, Whacks)
If WhacksFound Then
WhacksPattern = "\\\\\S*"
Flag = "1"
HostName = GetPattern(TheLine, WhacksPattern, Flag )
NBTable = GetNBTable(HostName)
MACPattern = "MAC Address = \S*"
Flag = "2"
MACAddress = GetPattern(NBTable, MACPattern, Flag )
NamePattern = "\S* <"
FLAG = "4"
PCname = GetPattern(NBTable, NamePattern, Flag )
PCname = Replace(PCname, " <", "")
PingReport = GetIPAddress(HostName)
PingPattern = "Reply from \S*"
Flag = "3"
IPAddress = GetPattern(PingReport, PingPattern, Flag )
IPAddress = Replace(IPAddress, ":", "")
Call AddToSpreadSheet(HostName, IPAddress, MACAddress, PCname)
End If
Loop
TheNVFile.Close
FileSystem.DeleteFile("C:\Windows\Temp\NetViewList.txt")
Dummy = WshShell.Popup ("Network Address Inventory Operation Complete",5,"Network Address Inventory Utility",64 )
Call SaveSpreadSheet()
Wscript.Quit
Sub BuildSpreadSheet()
XL.Visible = True
Set Book = XL.WorkBooks.Add
XL.Columns(1).ColumnWidth = 20
XL.Columns(2).ColumnWidth = 20
XL.Columns(3).ColumnWidth = 20
XL.Columns(4).ColumnWidth = 20
XL.Cells(1, 1).Value = "Host Name"
XL.Cells(1, 2).Value = "IP Address"
XL.Cells(1, 3).Value = "MAC Address"
XL.Cells(1, 4).Value = "PC Name"
XL.Range("A1:D1").Select
XL.Selection.Font.Bold = True
XL.Selection.Font.Size = 12
End Sub
Sub AddToSpreadSheet(HostName, IPAddress, MACAddress, PCname)
XL.Cells(Row, 1).Value = HostName
XL.Cells(Row, 2).Value = IPAddress
XL.Cells(Row, 3).Value = MACAddress
XL.Cells(Row, 4).Value = PCname
Row = Row + 1
XL.Cells(Row, 1).Select
End Sub
Sub SaveSpreadSheet()
TheDate = Date
TheDate = Replace(TheDate, "/", "-")
Suggestion = "NetAI " & TheDate & ".xls"
FileName = XL.GetSaveAsFilename(Suggestion)
If FileName <> False Then
Book.SaveAs(FileName)
End If
End Sub
Function FindPattern(TheText, ThePattern)
RegularExpression.Pattern = ThePattern
If RegularExpression.Test(TheText) Then
FindPattern = "True"
Else
FindPattern = "False"
End If
End Function
Function GetPattern(TheText, ThePattern, Flag)
RegularExpression.Pattern = ThePattern
Set Matches = RegularExpression.Execute(TheText)
For Each Match in Matches
TheMatch = Match.Value
If Flag = "1" Then TheMatch = Mid(TheMatch, 3)
If Flag = "2" Then TheMatch = Mid(TheMatch, 14)
If Flag = "3" Then TheMatch = Mid(TheMatch, 11)
If Flag = "4" Then TheMatch = Mid(Thematch, 1)
Next
GetPattern = TheMatch
End Function
Function GetNBTable(HostName)
NBCommand = "nbtstat -a " & HostName
WshShell.Run "command.com /c " & NBCommand &" > C:\Windows\Temp\NBTList.txt", 2,True
Set TheNBTFile = FileSystem.OpenTextFile("C:\Windows\Temp\NBTList.txt", ForReading, True)
GetNBTable = TheNBTFile.ReadAll
TheNBTFile.Close
FileSystem.DeleteFile("C:\Windows\Temp\NBTList.txt")
End Function
Function GetIPAddress(HostName)
IPCommand = "ping -n 1 " & HostName
WshShell.Run "command.com /c " & IPCommand &" > C:\Windows\Temp\IPList.txt", 2,True
Set TheIPFile = FileSystem.OpenTextFile("C:\Windows\Temp\IPList.txt", ForReading, True)
GetIPAddress = TheIPFile.ReadAll
TheIPFile.Close
FileSystem.DeleteFile("C:\Windows\Temp\IPList.txt")
End Function