Get a List of All the Users Whose Passwords Never Expire

Discussion in 'Scripting' started by Misha, Apr 12, 2006.

  1. Misha

    Misha Guest

    Hi all,

    I have to run the following script to Get a List of All the Users Whose
    Passwords Never Expire. Can someone please shed some light how to export the
    following to csv file?

    Here is the script itself:

    On Error Resume Next

    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") = 1000

    objCommand.CommandText = _
    "<LDAP://dc=fabrikam,dc=com>;" & _

    "(&(objectCategory=User)(userAccountControl:1.2.840.113556.1.4.803:=65536));"
    & _
    "Name;Subtree"
    Set objRecordSet = objCommand.Execute

    objRecordSet.MoveFirst
    Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
    Loop

    Many thanks,

    Misha
     
    Misha, Apr 12, 2006
    #1
    1. Advertisements

  2. Misha,

    assuming your script is called MyScript.vbs

    run it from the command line as follows;

    cscript myscript.vbs > users.csv

    Brian
    QA.com
     
    Brian McDermott, Apr 12, 2006
    #2
    1. Advertisements

  3. Misha

    Misha Guest

    Thanks Brian,

    Would you know if it's also possible to do the same from the script itself?

    What is the line I should add in order to do it without my interaction. I am
    planning to schedule a task to be run at the certain time and let the script
    create csv and export the results to it.

    Many thanks,

    Misha
     
    Misha, Apr 12, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.