Announcement

Collapse
No announcement yet.

Help with finding all users last login

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

  • Help with finding all users last login

    Hi,
    Im trying to run this scrip to find our users last login data across all domains

    http://cwashington.netreach.net/depo...tType=vbscript

    however, it keeps falling at the first hurdle
    "Syntax error. Usage: cscript badauths.vbs loginname"

    any idea what im doing wrong?
    do i have to specifiy my exact domain name somewhere or soemthing?
    however i thought this would have done that for me:

    Code:
    Function GetDCforDomain()
        Set oConnection = CreateObject("ADODB.Connection")
        Set oCommand = CreateObject("ADODB.Command")
        oConnection.Provider = "ADsDSOObject"
        oConnection.Open = "Active Directory Provider"
        Set oCommand.ActiveConnection = oConnection
    
        Set oRoot = GetObject("LDAP://RootDSE")
        strDomain = oRoot.Get("DefaultNamingContext")
        ' strDomain = DomainName
        DomainName = strDomain
        
        concat = "LDAP://OU=Domain Controllers," & strDomain                           'OU for Domain Controllers
        Set obj = GetObject(concat)

  • #2
    Re: Help with finding all users last login

    Requested movement to scripting forum.

    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


    • #3
      Re: Help with finding all users last login

      QUOTE:
      script USAGE:
      : cscript AllUsersLastLogon.vbs nbDomainName
      : AllUsersLastLogon.vbs nbDomainName


      There is this function in the script:
      Code:
      Function ControlSyntax()
          if wscript.arguments.count <> 1 Then
              wscript.echo "Syntax error. Usage: cscript badauths.vbs loginname"
              wscript.quit (5555)
          end If
          DomainName = "dc=" & wscript.arguments(0) & ",dc=local"
          DomainName2 = wscript.arguments(0) & ".local"
      End function
      Note: this is not a reliable DomainNameTranslation to set the variables for DomainName (dn) and DomainName2 (dns name) !
      And note that there is a fixed domainname extension hardcoded.

      further more...
      - the script expects that the DCs are in the default path: "OU=Domain Controllers, DC=domain,DC=local"
      - check also the Function DateCreationForUser(), where a domain dn is hardcoded
      - "ExcelPath" uses the Date function to generate the name of the file, in some countries the Date output contains signs invalid for the use in file and folder names.

      There seems to be so much cut&paste code in the script, that needs to be checked first.


      \Rems
      Last edited by Rems; 26th April 2008, 14:36. Reason: typo

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

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Help with finding all users last login

        Check out the OldCmp tool at http://www.joeware.net/freetools/tools/oldcmp/index.htm . It is designed to report on computer accounts but can be used on user accounts as well. Depending on the switches used, it will generate a report or move / delete accounts.
        blog.techscrawl.com

        Comment


        • #5
          Re: Help with finding all users last login

          OldCmp is a nice tool and clayshek is right, it works for user objects too.

          However OldComp.exe is based on the pwdLastSet attribute (last time the account password was reset!) in a Windows 2000 AD and a Windows 2003 AD. Only if your domain is at 'Windows Server 2003'-Domain Functional Level, there is a new attribute called lastLogonTimeStamp that can be used for sorting with OldCmp.exe.

          The lastLogonTimeStamp attribute is replicated in active directory.
          The lastLogonTimeStamp can also used with vbscripts.

          If the domain functional level is not 'Windows 2003' (default = 'Windows 2000 mixed'), then you can use the lastLogon attribute with a vbscript.
          Because of the fact that the lastLogon attribute is not replicated in Active Directory, a different value can be stored in the copy of Active Directory on each Domain Controller. So the script must query every DC and compare values afterwards.
          - http://forums.petri.com/showthread.p...7909#post97909
          - http://groups.google.com/group/micro...06b161214771b8


          \Rems

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

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment

          Working...
          X