'==========================================================================
'
' NAME: WhoIsLoggedInThereListVer.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYWRITE (c) 2005 All Rights Reserved
' DATE : 12/14/2005
'
' COMMENT: This script and many more are available in the Admin Script Pack
' by The Spider's Parlor. [URL unfurl="true"]http://www.TheSpidersParlor.com/vbscript[/URL]
'==========================================================================
On Error Resume Next
'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'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:" _
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
Report = Report & "UserName: " & objItem.UserName & " is logged in at computer " & strComputer & vbCrLf
Next
Next
Set ts = oFSO.CreateTextFile ("logreport.txt", ForWriting)
ts.write report