LogonType 10 is RemoteInteractive and covers both Interactive and Remote Terminal Services sessions. This is not avalible for Windows 2000
VBS Script:
strComputer = InputBox("Enter Terminal Server Name")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Logon Name"
objExcel.Cells(1, 2).Value = "Full Name"
objExcel.Cells(1, 3).Value = "Timestamp"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRts = objWMIService.ExecQuery _
("Select * from Win32_LogonSession Where LogonType = 10")
For Each objSession in colRts
Set colItems = objWMIService.ExecQuery("Associators of " _
& "{Win32_LogonSession.LogonId=" & objSession.LogonId & "} " _
& "Where AssocClass = Win32_LoggedOnUser Role = Dependent" )
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.Domain & "\" & objItem.Name
objExcel.Cells(intRow, 2).Value = objItem.FullName
objExcel.Cells(intRow, 3).Value = ConvWbemTime(objSession.StartTime)
Next
intRow = intRow + 1
Function ConvWbemTime(IntervalFormat)
sMonth = mid(IntervalFormat,5,2)
sDay = mid(IntervalFormat,7,2)
sYear = mid(IntervalFormat,1,4)
sHour = mid(IntervalFormat,9,2)
sMinutes = mid(IntervalFormat,11,2)
ConvWbemTime = sMonth & "-" & sDay & "-" & sYear & " " & sHour & ":" & sMinutes
End Function
objExcel.Range("A1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments