Advertisement

08.24.2007 at 01:27AM PDT, ID: 22784482
[x]
Attachment Details

Can anyone help me with this script

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0
Hi,

I got this script from this site.

Dim adoCon, adoCmdUser, adoRsUser, adoCmdOU, adoRsOU, objFSO, objFile, varTotalUsers, varMailEnabled

'Create the output file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\OU Info.txt", True)

'Create the ADODB Connection
Set adoCon = CreateObject("ADODB.Connection")
adoCon.CursorLocation = 3
adoCon.Provider = "ADsDSOObject"
adoCon.Open "ADSI"

'Create the User Recordset
Set adoCmdUser = CreateObject("ADODB.Command")
With adoCmdUser
      .ActiveConnection = adoCon
      .Properties("Size Limit") = 5000
      .Properties("Page Size") = 100
      .Properties("Timeout") = 30
      .Properties("Cache Results") = False
End With

'Create the OU Recordset
Set adoCmdOU = CreateObject("ADODB.Command")
With adoCmdOU
      .ActiveConnection = adoCon
                'Change YourDomainName on the following line to the name of your domain
      .CommandText = "SELECT adsPath FROM 'LDAP://development
Where objectClass='organizationalUnit'"
      .Properties("Size Limit") = 5000
      .Properties("Page Size") = 100
      .Properties("Timeout") = 30
      .Properties("Cache Results") = False
      Set adoRsOU = .Execute()
      Do Until adoRsOU.EOF
            'Get the number of users in the OU
            adoCmdUser.CommandText = "SELECT samAccountName FROM '" & Replace(adoRsOU.fields("ADsPath"), "'", "''") & "' Where objectClass='user' AND objectCategory='Person'"
            Set adoRsUser = adoCmdUser.Execute()
            varTotalUsers = adoRsUser.RecordCount
            'Get the number of mail enabled users in the OU
            adoCmdUser.CommandText = "SELECT samAccountName FROM '" & Replace(adoRsOU.fields("ADsPath"), "'", "''") & "' Where objectClass='user' AND objectCategory='Person' AND mailnickname='*'"
            Set adoRsUser = adoCmdUser.Execute()
            varMailEnabled = adoRsUser.RecordCount
            objFile.WriteLine adoRsOU.Fields("adsPath") & " Total=" & varTotalUsers & " Mail Enabled=" & varMailEnabled
            adoRsOU.MoveNext
      Loop
End With

'Clean up
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
Set adoRsOU = Nothing
Set adoCmdOU = Nothing
Set adoCmdUser = Nothing
Set adoCon = Nothing

I dont know why this does not output it creates a output file but no content in it.

Regards
Sharath
Answered By: RobSampson
Expert Since: 03/06/2007
Accepted Solutions: 2298
Computer Expertise: Advanced
RobSampson has been an Expert for 1 year 10 months, during which he has posted 9986 comments and answered 2298 questions. RobSampson is just one of 4024 experts in the Microsoft Operating Systems Zone. 4 experts collaborated on this answer, which was graded an "A" by the asker.
 
 
20081119-EE-VQP-48 / EE_QW_1_20070628