Announcement

Collapse
No announcement yet.

how to list disabled computer accounts

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

  • how to list disabled computer accounts

    Hello,
    i need a vbscript to list all disabled computer accounts in my win 2003 active directory domain. can anyone give me a sample code.
    Thanks a lot

  • #2
    Re: how to list disabled computer accounts

    something wrong with dsquery?
    http://www.robvanderwoude.com/adshel...y_computer.txt

    or is t their something wrong with the AD queries you can make via ADUC?
    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


    • #3
      Re: how to list disabled computer accounts

      hello dumber thanks for reply, i want to create a script that runs everyday at 7 o clock and list me disabled computer accounts and mail them to some persons. Because of this i want to make it with scripting. How can i do it with vbscript code.i find mailing code but i couldnt find disabled account listing.

      Comment


      • #4
        Re: how to list disabled computer accounts

        Related thread: userAccountControl differences

        You can do the same for computer accounts,
        Code:
        Set objRootDSE = GetObject("LDAP://rootDSE")
        strDNSDomain = objRootDSE.Get("defaultNamingContext")
        
        'Start the ADO connection
        Set objCommand = CreateObject("ADODB.Command")
        Set objConnection = CreateObject("ADODB.Connection")
        objConnection.Provider = "ADsDSOObject"
        objConnection.Open "Active Directory Provider"
        objCommand.ActiveConnection = objConnection
        
        'Set the ADO connection query strings
        StartNode = strDNSDomain
        SearchScope = "subtree"
        FilterString = "(&(objectclass=computer)" _
                     & "(userAccountControl:1.2.840.113556.1.4.803:=2))"
        Attributes = "adspath"
        
        'Create the LDAP-Query
        LDAPQuery = "<LDAP://" & StartNode & ">;" & FilterString & ";" _
                    & Attributes & ";" & SearchScope
        
        objCommand.CommandText = LDAPQuery
        objCommand.Properties("Page Size") = 100
        objCommand.Properties("Timeout") = 30
        objCommand.Properties("Cache Results") = False
        
        Set objRecordSet = objCommand.Execute
        
        If not objRecordSet.eof then 
          objRecordSet.MoveFirst
          Do Until objRecordset.EOF
            Set objItem = GetObject(objRecordSet.Fields("AdsPath").Value)
            strParentOU = Replace(objItem.parent, "LDAP://", "")
        
               ResultsLst = _
                    ResultsLst & objItem.cn & vbTab _
                     & "[" & strParentOU & "]" & vbNewLine
        
            Set objItem = Nothing
            objRecordSet.MoveNext
          Loop
        End If
        
        
        wscript.echo ResultsLst
        
        wscript.quit
        (How to query Active Directory by using a bitwise filter)


        \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


        • #5
          Re: how to list disabled computer accounts

          thank you very much rems.

          Comment

          Working...
          X