locked
to know to wich computers a user has been log on RRS feed

  • Question

  • Hello there. I want to get a list of computers to where a user has been log. I have got this using the adminstrative center of windows 2008 R2, but I need a script o something like that, because there are too many users, are above of 5000.

    thanks for your help

    Tuesday, May 31, 2011 5:18 AM

Answers

  • Hello,

    you can perform that using a logon script.

    You have to create a share and then use the following script:

    user: %username% computer: %computername% date: %date% > \\Server\Share\logon.txt

    where Server is the server name on which you created the share.

    You can use this script in a Batch file and you will get a text file which is logon.txt that where you can find the username, the used computername and the date of the logon.

     


    This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Microsoft Student Partner 2010 / 2011

    Microsoft Certified Professional

    Microsoft Certified Systems Administrator: Security

    Microsoft Certified Systems Engineer: Security

    Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration

    Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration

    Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuration

    Microsoft Certified Technology Specialist: Windows 7, Configuring

    Microsoft Certified IT Professional: Enterprise Administrator

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 8:08 AM
  • You can refer the below link for script as well as Psloggedon tool.

    http://gallery.technet.microsoft.com/scriptcenter/d46b1f3b-36a4-4a56-951b-e37815a2df0c

    http://technet.microsoft.com/en-us/sysinternals/bb897545

     

     

    Regards  


    Awinish Vishwakarma| CHECK MY BLOG  

    Disclaimer: This posting is provided AS-IS with no warranties or guarantees and confers no rights.

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 5:52 AM
  • Hello,

    that information is not stored in AD, so you have to use scripts to search the event viewer or you use a monitoring software that is capable to collect this information central like SCOM: http://www.microsoft.com/systemcenter/en/us/operations-manager.aspx


    Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 5:53 AM
  • Thanks a lot folks. I have resolved this problem. I used the next vbscript.

     

    On error resume next
    const ConForReading=1
    Const ForAppending =8

    Const ADS_SCOPE_SUBTREE=2
    const ArgSource = "C:\pruebas\script\buscar computadoras\buscarcompupornombre\archivo.txt"
    const Destino2="C:\pruebas\script\buscar computadoras\buscarcompupornombre\compusnoencontradas.txt"
    const Destino="C:\pruebas\script\buscar computadoras\buscarcompupornombre\resultados.txt"

    Set objConnection=CreateObject("ADODB.Connection")
    Set objCommand = CreateObject ("ADODB.Command")
    objConnection.Provider="ADsDSOObject"
    objConnection.open "Active Directory Provider"
    Set objCommand.ActiveConnection=objConnection
    objCommand.Properties("Page Size")=10000
    objCommand.Properties("Searchscope")=ADS_SCOPE_SUBTREE 

    Set objSysInfo = CreateObject("ADSystemInfo")
    Set oLogfile = CreateObject("Scripting.FileSystemObject")
    Set olnputFile =oLogFile.OpenTextFile(ArgSource,conForReading)


    set objFSO=CreateObject("Scripting.FileSystemObject")
    set objFile=objFSO.OpenTextFile(Destino,ForAppending)
    set objtels=objFSO.OpenTextFile(Destino2,ForAppending)

    While olnputFile.AtEndOfStream <> True
     strText=olnputFile.ReadLine
     samacount=strText & "*"      ' This asterisk is veeeryyy important, because is a wild card
     
     
     prueba="select name from 'LDAP://dc=dssat,dc=sat,dc=gob,dc=mx' where objectCategory='computer' " &  _
            "and Name='" & samacount & "'"

     objCommand.CommandText=prueba
     set objRecordSet=objCommand.Execute 
     if objRecordSet.RecordCount=0 then
      objFile.Writeline(strText)
     else
      
      bandera=1
      totalchain=""
      objRecordSet.movefirst
      do until objRecordSet.eof
       if bandera=1 then
        'objFile.Writeline(strText & "," & objRecordSet.fields("name").value)
        totalchain=strText & "," & objRecordSet.fields("name").value

        bandera=bandera+1
       else
        'objFile.Writeline("," & objRecordSet.fields("name").value
        totalchain=totalchainl & "," & objRecordSet.fields("name").value  
        
       end if
       
       objRecordSet.movenext
      loop

      objFile.Writeline(totalchain)


      
     end if

    wend 
    objFile.close
    olnputFile.close
    wscript.echo "operation ended"

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 9:31 AM
  • Another option is to get the user profile information from the computer.  Here is the PowerShell script.

    http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX

    Blogs - http://blogs.sivarajan.com/
    Articles - http://www.sivarajan.com/publications.html
    Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
    This posting is provided AS IS with no warranties,and confers no rights.
    • Marked as answer by luismendeze Friday, June 3, 2011 4:44 AM
    Tuesday, May 31, 2011 11:32 AM

All replies

  • You can refer the below link for script as well as Psloggedon tool.

    http://gallery.technet.microsoft.com/scriptcenter/d46b1f3b-36a4-4a56-951b-e37815a2df0c

    http://technet.microsoft.com/en-us/sysinternals/bb897545

     

     

    Regards  


    Awinish Vishwakarma| CHECK MY BLOG  

    Disclaimer: This posting is provided AS-IS with no warranties or guarantees and confers no rights.

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 5:52 AM
  • Hello,

    that information is not stored in AD, so you have to use scripts to search the event viewer or you use a monitoring software that is capable to collect this information central like SCOM: http://www.microsoft.com/systemcenter/en/us/operations-manager.aspx


    Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 5:53 AM
  • Hello,

    you can perform that using a logon script.

    You have to create a share and then use the following script:

    user: %username% computer: %computername% date: %date% > \\Server\Share\logon.txt

    where Server is the server name on which you created the share.

    You can use this script in a Batch file and you will get a text file which is logon.txt that where you can find the username, the used computername and the date of the logon.

     


    This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Microsoft Student Partner 2010 / 2011

    Microsoft Certified Professional

    Microsoft Certified Systems Administrator: Security

    Microsoft Certified Systems Engineer: Security

    Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration

    Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration

    Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuration

    Microsoft Certified Technology Specialist: Windows 7, Configuring

    Microsoft Certified IT Professional: Enterprise Administrator

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 8:08 AM
  • Thanks a lot folks. I have resolved this problem. I used the next vbscript.

     

    On error resume next
    const ConForReading=1
    Const ForAppending =8

    Const ADS_SCOPE_SUBTREE=2
    const ArgSource = "C:\pruebas\script\buscar computadoras\buscarcompupornombre\archivo.txt"
    const Destino2="C:\pruebas\script\buscar computadoras\buscarcompupornombre\compusnoencontradas.txt"
    const Destino="C:\pruebas\script\buscar computadoras\buscarcompupornombre\resultados.txt"

    Set objConnection=CreateObject("ADODB.Connection")
    Set objCommand = CreateObject ("ADODB.Command")
    objConnection.Provider="ADsDSOObject"
    objConnection.open "Active Directory Provider"
    Set objCommand.ActiveConnection=objConnection
    objCommand.Properties("Page Size")=10000
    objCommand.Properties("Searchscope")=ADS_SCOPE_SUBTREE 

    Set objSysInfo = CreateObject("ADSystemInfo")
    Set oLogfile = CreateObject("Scripting.FileSystemObject")
    Set olnputFile =oLogFile.OpenTextFile(ArgSource,conForReading)


    set objFSO=CreateObject("Scripting.FileSystemObject")
    set objFile=objFSO.OpenTextFile(Destino,ForAppending)
    set objtels=objFSO.OpenTextFile(Destino2,ForAppending)

    While olnputFile.AtEndOfStream <> True
     strText=olnputFile.ReadLine
     samacount=strText & "*"      ' This asterisk is veeeryyy important, because is a wild card
     
     
     prueba="select name from 'LDAP://dc=dssat,dc=sat,dc=gob,dc=mx' where objectCategory='computer' " &  _
            "and Name='" & samacount & "'"

     objCommand.CommandText=prueba
     set objRecordSet=objCommand.Execute 
     if objRecordSet.RecordCount=0 then
      objFile.Writeline(strText)
     else
      
      bandera=1
      totalchain=""
      objRecordSet.movefirst
      do until objRecordSet.eof
       if bandera=1 then
        'objFile.Writeline(strText & "," & objRecordSet.fields("name").value)
        totalchain=strText & "," & objRecordSet.fields("name").value

        bandera=bandera+1
       else
        'objFile.Writeline("," & objRecordSet.fields("name").value
        totalchain=totalchainl & "," & objRecordSet.fields("name").value  
        
       end if
       
       objRecordSet.movenext
      loop

      objFile.Writeline(totalchain)


      
     end if

    wend 
    objFile.close
    olnputFile.close
    wscript.echo "operation ended"

    • Marked as answer by luismendeze Tuesday, May 31, 2011 9:31 AM
    Tuesday, May 31, 2011 9:31 AM
  • Another option is to get the user profile information from the computer.  Here is the PowerShell script.

    http://portal.sivarajan.com/2010/07/user-profile-and-os-info-powershell.html


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+ Houston, TX

    Blogs - http://blogs.sivarajan.com/
    Articles - http://www.sivarajan.com/publications.html
    Twitter: @santhosh_sivara - http://twitter.com/santhosh_sivara
    This posting is provided AS IS with no warranties,and confers no rights.
    • Marked as answer by luismendeze Friday, June 3, 2011 4:44 AM
    Tuesday, May 31, 2011 11:32 AM
  • One other option would be to use the freeware tool, LimitLogon.
    http://technet.microsoft.com/en-us/magazine/2005.05.utilityspotlight.aspx

    --
    Paul Bergson
    MVP - Directory Services
    MCITP: Enterprise Administrator
    MCTS, MCT, MCSE, MCSA, Security+, BS CSci
    2008, Vista, 2003, 2000 (Early Achiever), NT4
    http://www.pbbergs.com    Twitter @pbbergs
    http://blogs.dirteam.com/blogs/paulbergson

    Please no e-mails, any questions should be posted in the NewsGroup. This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, May 31, 2011 12:03 PM