Results 1 to 4 of 4

Thread: Dumping logon name and logon script values to a text file - blank logon script field

  1. #1
    Phil McNeill Guest

    Dumping logon name and logon script values to a text file - blank logon script field

    A while back someone here was kind enough to provide me with the following
    script and advice on how to dump these two values to a text file. It worked
    great except for one thing. If the user had no logon script, they were
    ignored by the script and didn't appear at all in the output. I am hoping
    someone can tell me what I'd need to modify in the script below to dump a
    list of the AD users with blank Logon Script values.

    Thanks!



    "Option Explicit

    Dim adoCommand, adoConnection, strBase, strFilter, strAttributes

    Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strScript



    ' Setup ADO objects.

    Set adoCommand = CreateObject("ADODB.Command")
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    adoCommand.ActiveConnection = adoConnection



    ' Search entire Active Directory domain.

    Set objRootDSE = GetObject("LDAP://RootDSE")

    strDNSDomain = objRootDSE.Get("defaultNamingContext")
    strBase = "<LDAP://" & strDNSDomain & ">"


    ' Filter on user objects.
    strFilter = "(&(objectCategory=person)(objectClass=user))"



    ' Comma delimited list of attribute values to retrieve.
    strAttributes = "sAMAccountName,scriptPath"



    ' Construct the LDAP syntax query.
    strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
    adoCommand.CommandText = strQuery
    adoCommand.Properties("Page Size") = 100
    adoCommand.Properties("Timeout") = 30
    adoCommand.Properties("Cache Results") = False



    ' Run the query.
    Set adoRecordset = adoCommand.Execute


    ' Enumerate the resulting recordset.
    Do Until adoRecordset.EOF

    ' Retrieve values and display.
    strName = adoRecordset.Fields("sAMAccountName").Value

    strScript = adoRecordset.Fields("scriptPath").value

    Wscript.Echo strName & "," & strScript

    ' Move to the next record in the recordset.
    adoRecordset.MoveNext
    Loop



    ' Clean up.

    adoRecordset.Close

    adoConnection.Close

    ===========



  2. #2
    Richard Mueller [MVP] Guest

    Re: Dumping logon name and logon script values to a text file - blank logon script field

    I believe the script will dump out all users, but if the scriptPath
    attribute has no value, strScript may be null, which could raise an error. I
    would suggest appending a blank string to prevent this. For example:

    strScript = adoRecordset.Fields("scriptPath").value & ""

    Next, if you want to only document users that have no value assigned to
    scriptPath, use this filter:

    strFilter = "(&(objectCategory=person)(objectClass=user)(!scriptPath=*))"

    If you only want to document users that have a value assigned to scriptPath,
    use:

    strFilter = "(&(objectCategory=person)(objectClass=user)(scriptPath=*))"

    --
    Richard Mueller
    MVP Directory Services

    --

  3. #3
    Phil McNeill Guest

    Re: Dumping logon name and logon script values to a text file - blank logon script field

    You're correct, it does. My bad. I had generated the CSV a few weeks back,
    edited out the users with no value in the scripts column, and forgotten I'd
    edited it.

    Time for a holiday...

    Thank you!

  4. #4
    Join Date
    Aug 2010
    Posts
    1

    Re: Dumping logon name and logon script values to a text file - blank logon script field

    Hi guys,

    I was exactly looking for this kind of script since a few months and I'm glad I find it here. I just have one problem, I don't know how to export it into a .csv format so it will be easier for me to extract the data.

    Do you know what line I need to add and where exactly in the script?

    I'm a newbie in vbs scripting, but I find it great!

    Thanks!

    Mathieu

    P.S Sorry for my english, it's not my first language.

Similar Threads

  1. Run logon script
    By Sandy22 in forum Operating Systems
    Replies: 6
    Last Post: 08-06-2010, 10:16 AM
  2. Bat file for logon script
    By adam2010 in forum Windows Software
    Replies: 1
    Last Post: 10-05-2010, 11:42 AM
  3. Logon Script Does Not Work
    By c54618 in forum Operating Systems
    Replies: 1
    Last Post: 01-05-2008, 08:40 AM
  4. domain logon script does not run
    By Onetoomany in forum Windows Server Help
    Replies: 4
    Last Post: 11-02-2008, 05:37 AM
  5. logon script help
    By HandelMan in forum Small Business Server
    Replies: 1
    Last Post: 31-01-2008, 03:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,660,794.90314 seconds with 17 queries