Announcement

Collapse
No announcement yet.

last logon script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • last logon script

    This is a script that I combined some samples with. I want to get the last logon from all the users in the domain that haven't logged in about 60 days, and then export the data to an excel spread sheet. Can someone help me with this?

    Set objUser = GetObject("LDAP://cn=Ken Myer, ou=Finance, dc=fabrikam, dc=com")
    Set objLastLogon = objUser.Get("lastLogonTimestamp")
    Set objExcel = createobject("Excel.application")

    intLastLogonTime = objLastLogon.HighPart * (2^32) + objLastLogon.LowPart
    intLastLogonTime = intLastLogonTime / (60 * 10000000)
    intLastLogonTime = intLastLogonTime / 1440

    Wscript.Echo "Last logon time: " & intLastLogonTime + #1/1/1601#


    'write to excel file

    objexcel.Visible = True
    objexcel.Workbooks.add
    objexcel.Cells(1, 1).Value = "Testing"
    objexcel.ActiveWorkbook.SaveAs("c:\exceltest.xls")
    objexcel.Quit

  • #2
    Re: last logon script

    I just found this website....might help.

    http://www.windowsitpro.com/Article/...113/15113.html

    Comment


    • #3
      Re: last logon script

      Also check out oldcmp by joe: http://www.joeware.net/win/free/tools/oldcmp.htm

      It can generate reports in HTML/DHTML/CSV of what you want (check out the examples at the bottom).
      Guy Teverovsky
      "Smith & Wesson - the original point and click interface"

      Comment


      • #4
        Re: last logon script

        Originally posted by guyt
        Also check out oldcmp by joe: http://www.joeware.net/win/free/tools/oldcmp.htm

        It can generate reports in HTML/DHTML/CSV of what you want (check out the examples at the bottom).
        Does oldcmp only tell you computer accounts that have not reset their password in x number of days. I didnt think it worked for user accounts??

        Michael
        Michael Armstrong
        www.m80arm.co.uk
        MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

        ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

        Comment


        • #5
          Re: last logon script

          Code:
          -users            Work on user accounts instead of computer accounts.
          Guy Teverovsky
          "Smith & Wesson - the original point and click interface"

          Comment


          • #6
            Re: last logon script

            This tool is awesome, thanks for letting me know about it!

            Comment


            • #7
              Re: last logon script

              I wish this had a option to write to an excel file.

              Comment


              • #8
                Re: last logon script

                Originally posted by guyt
                Code:
                -users            Work on user accounts instead of computer accounts.
                Ahh, never noticed that switch before.

                He's a very clever guy is joe and I always enjoy reading his blog - A very well respected guy
                Michael Armstrong
                www.m80arm.co.uk
                MCITP: EA, MCTS, MCSE 2003, MCSA 2003: Messaging, CCA, VCP 3.5, 4, 5, VCAP5-DCD, VCAP5-DCA, ITIL, MCP, PGP Certified Technician

                ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

                Comment


                • #9
                  Re: last logon script

                  Originally posted by ekrengel
                  I wish this had a option to write to an excel file.
                  you can write to a CSV file, which you can open into excel.
                  Marcel
                  Technical Consultant
                  Netherlands
                  http://www.phetios.com
                  http://blog.nessus.nl

                  MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
                  "No matter how secure, there is always the human factor."

                  "Enjoy life today, tomorrow may never come."
                  "If you're going through hell, keep going. ~Winston Churchill"

                  Comment


                  • #10
                    Re: last logon script

                    K i'll give that a try, thanks.

                    Comment

                    Working...
                    X