'==========================================================================
'
' NAME: ReportLogonLocationsByPC.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE : 3/11/2004
'
' COMMENT: <comment>
'
'==========================================================================
On Error Resume Next
'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
'open the data file
Set oTextStream = oFSO.OpenTextFile("wslist.txt")
'make an array from the data file
RemotePC = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
For Each strComputer In RemotePC
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkConnection",,48)
Report = ""
For Each objItem in colItems
Report = Report & "UserName: " & objItem.UserName & " is logged in at " & strComputer & vbCrLf
Exit For
Next
Next
Set ts = oFSO.CreateTextFile ("LogonLocationReport.txt", ForWriting)
ts.write Report
Set oTextStream = nothing
set ts = nothing
set oFSO = nothing