********************************************************************************** whoislog.vbs ********************************************************************************** On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 OutputFile="c:\scripts\whoisloggedon.txt" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.CreateTextFile(OutputFile, True) InputFile="c:\scripts\OU.txt" Set ifile = iFSO.OpenTextFile(inputfile) Do until ifile.AtEndOfLine strComputerContainer = ifile.ReadLine Set objContainer = GetObject("LDAP://" & strComputerContainer) objContainer.Filter = Array("Computer") 'Set StdOut = WScript.StdOut Set objShell = CreateObject("WScript.Shell") Dim strAdminResults Dim strGuestResults on error resume next For Each objComputer In objContainer strComputer = Split(objComputer.Name, "=")(1) oFile.WriteLine now() oFile.WriteLine(" ") oFile.WriteLine("Computer: " & strComputer) oFile.WriteLine("---------------------------------------------------") Set objScriptExec = objShell.Exec("psloggedon" & " \\" & strComputer) strLoggedOnResults = LCase(objScriptExec.StdOut.ReadAll) oFile.WriteLine(strLoggedOnResults ) Next loop MsgBox "Processing Done " Function WMIDateStringToDate(dtmDate) WScript.Echo dtm: WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2)) End Function ********************************************************************************** OU.TXT Modify the the text below to reflect your AD structure the DC site is your FQDN split out and the ou side is your tree backwards order _MYSITE being the root ********************************************************************************** ou=Equipment-Laptop,ou=BLDG1,ou=HQ,ou=US,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org ou=Equipment-PC,ou=BLDG2,ou=FINANCE,ou=ITALY,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org ou=Equipment-Servers,ou=BLDG1,ou=PROD,ou=GERMANY,ou=_MYSITE,dc=eur,dc=ds,dc=exterm,dc=org