1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Last Login to DC script

Discussion in 'Windows Server System' started by autumn801, 2010/05/26.

  1. 2010/05/26
    autumn801

    autumn801 Inactive Thread Starter

    Joined:
    2010/05/26
    Messages:
    3
    Likes Received:
    0
    Does anyone have a script that gives you the last logon to the DC of their network?

    I'm looking for a script that gives me a list of users last logon to the DC.

    I'm not a scripting person that is why I am asking.

    Thanks
     
  2. 2010/05/27
    MichaelF

    MichaelF Inactive

    Joined:
    2009/07/01
    Messages:
    49
    Likes Received:
    0
    ...just to make the task more precise: 1) "last logon" ... "last" from what time???
    2) what kind of logon are you interested in - "account logon" or "network logon "?
     

  3. to hide this advert.

  4. 2010/05/27
    autumn801

    autumn801 Inactive Thread Starter

    Joined:
    2010/05/26
    Messages:
    3
    Likes Received:
    0
    I'm looking for a script that pulls from AD all users and specify their last logon.

    That is all.

    Just the last time they logged onto the network.

    thanks
     
  5. 2010/05/28
    MichaelF

    MichaelF Inactive

    Joined:
    2009/07/01
    Messages:
    49
    Likes Received:
    0
    If your AD infrastrucure supports Last-Logon-Timestamp you can use this script:

    ' This code prints the last logon timestamp for a user.
    ' ------ SCRIPT CONFIGURATION ------
    strUserDN = "<UserDN>" ' e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
    ' ------ END CONFIGURATION ---------

    set objUser = GetObject( "LDAP://" & strUserDN)
    set objLogon = objUser.Get( "lastLogonTimestamp ")
    intLogonTime = objLogon.HighPart * (2^32) + objLogon.LowPart
    intLogonTime = intLogonTime / (60 * 10000000)
    intLogonTime = intLogonTime / 1440
    WScript.Echo "Approx last logon timestamp: " & intLogonTime + #1/1/1601#

    Look here:
    http://ondotnet.com/pub/a/dotnet/excerpt/ADcookbook_chap1/index.html?page=2)
     
  6. 2010/05/28
    MichaelF

    MichaelF Inactive

    Joined:
    2009/07/01
    Messages:
    49
    Likes Received:
    0

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.