+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25
How do you do....it? Thread, Who has logged on where? in Technical; Your web filter may keep such things in its logs. These things might be rather well hidden......
  1. #16


    tom_newton's Avatar
    Join Date
    Sep 2006
    Location
    Leeds
    Posts
    4,507
    Thank Post
    871
    Thanked 862 Times in 681 Posts
    Rep Power
    199
    Your web filter may keep such things in its logs. These things might be rather well hidden...

  2. #17

    Join Date
    Jan 2012
    Posts
    86
    Thank Post
    1
    Thanked 4 Times in 4 Posts
    Rep Power
    7
    Not all users, use the internet tho or user may only use local hosted sites which the webfilter will not pick up

  3. #18

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468
    Quote Originally Posted by internetuser View Post
    Any way to get this to write to a database, either via a bat or vbs/powershell ?
    There is one on here some place that will go to an access database. The issue was it got full fairly quick.

  4. #19

    Join Date
    Apr 2010
    Posts
    2,169
    Thank Post
    111
    Thanked 192 Times in 159 Posts
    Rep Power
    85

  5. #20


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    7,059
    Thank Post
    232
    Thanked 926 Times in 795 Posts
    Rep Power
    309
    im currently writng a better version of my script its about half the lines and atm dumps to csv will be adding ad (with comparison to current data when i get time and am in the right frame of mind to code)

  6. #21
    ninjabeaver's Avatar
    Join Date
    Jun 2005
    Location
    Norfolk
    Posts
    1,090
    Thank Post
    183
    Thanked 100 Times in 88 Posts
    Rep Power
    47
    I'll keep an eye out for that then.

  7. #22


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    7,059
    Thank Post
    232
    Thanked 926 Times in 795 Posts
    Rep Power
    309
    for what its worth current code (just dumps to csv and no last logged on user im trying to find a good solution for xp and win7 atm guessing that may be a case of copying a local file into it but not 100% sure atm

    Code:
    Option Explicit
    'On Error Resume Next
    
    dim outputstring, computermodel, cpu, ram, hddcapacity, hddfree, serialno, macaddress, operatingsystem
    dim stcomputer, colitems, objItem, colcpu, colPhysicalMemory, objPhysicalMemory, intMemory, colDisks, objhdd
    dim colComputerSystem, colOperatingSystems, objOperatingSystem, colBIOS, objBIOS, colnicconfig, objnicconfig
    dim objwmiservice, hddtemp
    Dim strDirectory, strFile, strText, WshNetwork, wshShell, pcname, objFSO, objFolder, objFile, objTextFile
    
    stcomputer = "."
    
    Set objWMIService = GetObject("winmgmts:\\" & stcomputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") 
    Set colcpu = objWMIService.ExecQuery("Select * from Win32_Processor")
    Set colPhysicalMemory = objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
    set coldisks = objWMIService.ExecQuery("Select * From Win32_LogicalDisk") 
    Set colComputerSystem = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    Set colBIOS = objWMIService.ExecQuery("Select * From Win32_BIOS")
    Set colnicconfig = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    
    pcname = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
    strDirectory = "\\server1\logs$\pc\"
    strFile = pcname & ".csv"
    
    'make-model
    For Each objItem In colItems 
    	computermodel= objItem.Manufacturer & " " & objItem.Model
    	'wscript.echo computermodel
    Next
    
    'cpu info
    For Each objItem in colcpu
        cpu = objItem.Name
    	'wscript.echo cpu
    Next
    
    'ram
    If Not colPhysicalMemory Is Nothing Then
    	 intMemory = 0
    	 For Each objPhysicalMemory In colPhysicalMemory
    		 intMemory = intMemory + Int(objPhysicalMemory.Capacity)
    	 Next
    	 ram = (intMemory / 1024 / 1024 ) & " MB"
    	 'wscript.echo ram
    End If
    
    'hdd capacity
    for each objhdd in coldisks
    	If objhdd.DeviceID = "C:" Then
    		hddcapacity = int(objhdd.Size/1073741824) & " GB"
    		hddfree = int(objhdd.freespace/1073741824) & " GB"
    		'wscript.echo hddfree
    	end if
    next
    
    'windows version
    For Each objOperatingSystem in colOperatingSystems
        operatingsystem = objOperatingSystem.Caption & " sp " & objOperatingSystem.ServicePackMajorVersion
    	'wscript.echo operatingsystem
    Next
    
    'serial no
    If Not colBIOS Is Nothing Then
    	 For Each objBIOS in colBIOS
    		 serialno = objBIOS.SerialNumber
    		 'wscript.echo serialno
    	 Next
    End If
    
    'mac address(s)
    If Not colnicconfig Is Nothing Then
    	 For Each objnicconfig in colnicconfig
    		 If macaddress <> "" Then
    			 macaddress = macaddress & ", "
    		 End If
    		 macaddress = macaddress & objnicconfig.MACAddress
    		 'wscript.echo macaddress
    	 Next
    End If
    
    'concatanate data for output
    outputstring = pcname & "," & computermodel & "," & cpu &"," & ram &"," & hddcapacity& "," & hddfree & "," & serialno & "," & operatingsystem & "," & macaddress
    'wscript.echo outputstring
    
    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    ' Check that the strDirectory folder exists
    If objFSO.FolderExists(strDirectory) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFolder = objFSO.CreateFolder(strDirectory)
       'WScript.Echo "Just created " & strDirectory
    End If
    
    If objFSO.FileExists(strDirectory & strFile) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
    Else
       Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
       'Wscript.Echo "Just created " & strDirectory & strFile
    End If 
    
    set objFile = nothing
    set objFolder = nothing
    ' OpenTextFile Method needs a Const value
    ' ForAppending = 8 ForReading = 1, ForWriting = 2
    Const ForAppending = 2
    
    Set objTextFile = objFSO.OpenTextFile _
    (strDirectory & strFile, ForAppending, True)
    
    ' Writes result every time you run this VBScript
    objTextFile.WriteLine(outputstring)
    objTextFile.Close
    to make it read better with multiple pcs i create a 01.csv with column headers (01 as thats alphabeticaly about as low as i can get then run a script to merge them all into one big csv
    Code:
    del "D:\pc\logs\pc\all.csv" /q
    copy "D:\pc\logs\pc\*.csv" "D:\pc\logs\pc\all.csv" /y

  8. #23

    Join Date
    May 2011
    Location
    Kingston
    Posts
    9
    Thank Post
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    This is fantastic! Just gave it a try and love the results. Thanks so much, James.

    Quote Originally Posted by FN-GM View Post
    I use these batch files at logon and logoff

    Code:
    rem The following line creates a rolling log file of usage by workstation
    echo Log In %Date% %TIME% %USERNAME% >> \\server\share\%COMPUTERNAME%.log
    
    rem The following line creates a rolling log file of usage by user
    echo Log In %Date% %TIME% %COMPUTERNAME% >> \\server\share\%USERNAME%.log

    Code:
    rem The following line creates a rolling log file of usage by workstation
    echo Log Out %Date% %TIME% %USERNAME% >> \\server\share\%COMPUTERNAME%.log
    
    rem The following line creates a rolling log file of usage by user
    echo Log Out %Date% %TIME% %COMPUTERNAME% >> \\server\share\%USERNAME%.log

  9. #24

    Join Date
    Dec 2011
    Location
    Cincinnati
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Login Tracking

    Quote Originally Posted by RiffRaff View Post
    Can anybody tell me how I can get a log of of all our pupils and staff logons?

    It's mainly to be able to show who was sat a particular PC at a particular time (in the event of vandalism etc.)

    Thanks
    Here is my simple vbs script on login which posts login time, name, and computer to an SQL Table. (It also puts the last logged in user and timestamp in the AD computer comment..) Call it from Group Policy Login Script.


    'On Error Resume Next

    Set objSysInfo = CreateObject("ADSystemInfo") 'Bind to AD
    Set objNet = CreateObject("WScript.Network")

    strCompDN = objSysInfo.ComputerName 'DN for computer, e.g. "CN=VISTAWORKSTATION,OU=Child OU Name,OU=Parent OU Name,DC=domain,DC=com"

    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )



    strCompName = objSysInfo.ComputerName

    Set objComp = GetObject("LDAP://" & strCompDN) 'IADsComputer object

    strUserDN = objSysInfo.UserName 'DN for user, e.g. "CN=John Smith,OU=Child OU Name,OU=Parent OU Name,DC=domain,DC=com"
    Set objUser = GetObject("LDAP://" & strUserDN) 'IADsUser object

    strUsrLogin = LCase(objNet.UserName)

    'Parse out datestamp in text format.
    strNow = Now
    strDateStamp = DatePart("yyyy",strNow) & _
    Right("0" & DatePart("m",strNow), 2) & _
    Right("0" & DatePart("d",strNow), 2) & _
    "@" & _
    Right("0" & DatePart("h",strNow), 2) & _
    Right("0" & DatePart("n",strNow), 2)

    'RegExp object used to perform a simple match on IP address
    Set objRE = New RegExp
    objRE.IgnoreCase = True
    'Note this regexp pattern isn't "correct" for matching an IPv4 address properly, but since WMI will return an
    'array of IP addresses, this is sufficient to distinguish IPv4 vs IPv6
    objRE.Pattern = "^\d+\.\d+\.\d+\.\d+$"

    strIP = ""

    'Connect to WMI and retreive all network adapters
    Set objWMI = GetObject("winmgmts:")
    Set colNICs = objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")

    'Get the IP(s) assigned to whichever network adapter has our default gateway
    If colNICs.Count > 0 Then
    For Each objNIC in colNICs
    If IsArray(objNIC.DefaultIPGateway) Then
    arrIP = objNIC.IPAddress
    For i = 0 To UBound(arrip)
    If objRE.Test(arrIP(i)) Then strIP = strIP & " " & arrIP(i)
    Next
    strMAC = objNIC.MACAddress
    End If
    Next
    End If

    strIP = Trim(strIP)

    objComp.Description = strDateStamp & " " & strUsrLogin & " " & strIP
    'Or, put them in separate attributes in AD
    'objComp.Put "extensionAttribute1", strUsrLogin
    'objComp.Put "extensionAttribute2", strIP
    'objComp.Put "extensionAttribute3", strMAC
    objComp.Setinfo


    strLogFile = "'" & strComputerName & "', '" & strNow & "','" & strUsrLogin & "','" & strIP & "'"
    'wscript.echo strLogFile

    Const DB_CONNECT_STRING = "Provider=SQLOLEDB.1;Data Source=SqlServerName;Initial Catalog=Database;user id ='SqlUser';password='SqlPassword'"
    Set myConn = CreateObject("ADODB.Connection")
    Set myCommand = CreateObject("ADODB.Command" )
    myConn.Open DB_CONNECT_STRING
    Set myCommand.ActiveConnection = myConn
    strCommandString = "INSERT INTO table_ComputerLog (ComputerName,LoginTime,Username,IPv4) VALUES( "
    strCommandString = strCommandString & strLogFile & ")"



    myCommand.CommandText = strCommandString
    myCommand.Execute
    myConn.Close


    Set objWMI = nothing
    Set colNICs = nothing

  10. #25
    AJWhite1970's Avatar
    Join Date
    Sep 2012
    Location
    Wiltshire
    Posts
    355
    Thank Post
    96
    Thanked 82 Times in 62 Posts
    Rep Power
    18
    My file is similar to most with a couple of extra logs created:

    echo LOGIN %date%, %time%, %computername%, %username%, >> \\server\apps\OCS\Logs\login.csv
    echo LOGIN %date%, %time%, %computername%, %username%, >> \\server\apps\OCS\Logs\Users\%username%.csv
    echo LOGIN %date%, %time%, %computername%, %username%, >> \\server\apps\OCS\Logs\PCs\%computername%.csv
    echo LOGIN %date%, %time%, %logonserver%, %computername%, %username%, >> \\server\apps\OCS\Logs\Domain\%logonserver%.csv

    1) rolling record of every login
    2) login history per user
    3) login history per PC
    4) rolling record of logins serviced by DC (very quick reference guide to see load balancing is working)

    Andrew



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. restricting who can log on to a certain machine
    By RabbieBurns in forum Windows
    Replies: 8
    Last Post: 2nd May 2008, 03:37 PM
  2. finding out who has logged into a PC in AD
    By Oops_my_bad in forum Windows
    Replies: 6
    Last Post: 22nd November 2007, 04:51 PM
  3. Who is (logged) on..
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 5th August 2007, 01:06 PM
  4. Seeing who is logged on
    By faza in forum Wireless Networks
    Replies: 5
    Last Post: 6th December 2006, 10:19 AM
  5. Who last logged on
    By danIT in forum Windows
    Replies: 1
    Last Post: 2nd October 2006, 10:08 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •