Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



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

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-08-2008
Phil McNeill
 
Posts: n/a
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

===========



Reply With Quote
  #2  
Old 13-08-2008
Richard Mueller [MVP]
 
Posts: n/a
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

--
Reply With Quote
  #3  
Old 14-08-2008
Phil McNeill
 
Posts: n/a
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!
Reply With Quote
  #4  
Old 17-08-2010
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Dumping logon name and logon script values to a text file - blank logon script field"
Thread Thread Starter Forum Replies Last Post
Run logon script Sandy22 Operating Systems 6 08-06-2010 10:16 AM
Bat file for logon script adam2010 Windows Software 1 10-05-2010 11:42 AM
Logon Script Does Not Work c54618 Operating Systems 1 01-05-2008 08:40 AM
domain logon script does not run Onetoomany Windows Server Help 4 11-02-2008 04:37 AM
logon script help HandelMan Small Business Server 1 31-01-2008 02:26 AM


All times are GMT +5.5. The time now is 09:51 AM.