Advertisement

05.20.2008 at 12:08PM PDT, ID: 23418459
[x]
Attachment Details
[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!

9.4

Vbscript output to .csv file

Asked by Brian08 in VB Script, Windows 2003 Server, Scripting Languages

Tags: ,

I found this script that will read the local administrators groups on a member and report the nested groups members that it contants. I need some help getting this to output to .csv file. I am new to using vbscript and I am stuck on this. I have used dumpsec for the task but it would not report the nested group members.

I also need to be able to read all the local groups on the machine and do the same output but I think I might could figure that out. The important thing is getting the output done.

Thanks in advance
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
' EnumLocalGroup.vbs
' VBScript program to enumerate members of a local group.
'
' ----------------------------------------------------------------------
' Copyright (c) 2007 Richard L. Mueller
' Hilltop Lab web site - http://www.rlmueller.net
' Version 1.0 - April 5, 2007
' Version 1.1 - July 31, 2007 - Escape any "/" characters in group DN's.
' A VBScript program demonstrating how to enumerate members of a local
' group. Reveals direct membership in the local group, membership in
' nested local groups, membership in domain groups that are members of
' the local group, and membership in nested domain groups.
'
' You have a royalty-free right to use, modify, reproduce, and
' distribute this script file in any way you find useful, provided that
' you agree that the copyright owner above has no warranty, obligations,
' or liability for such use.
 
Option Explicit
 
Dim objNetwork, objLocalGroup
 
' These attributes must be declared in the main program,
' so they are global in scope.
Dim objTrans, strComputer, strNetBIOSDomain
 
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
 
' Determine NetBIOS name of domain and local computer.
Set objNetwork = CreateObject("Wscript.Network")
strNetBIOSDomain = objNetwork.UserDomain
strComputer = objNetwork.ComputerName
Set objNetwork = Nothing
 
' Bind to local Administrators group.
Set objLocalGroup = GetObject("WinNT://" & strComputer _
    & "/Administrators,group")
 
' Enumerate members of the local group.
Call EnumLocalGroup(objLocalGroup)
 
Sub EnumLocalGroup(ByVal objGroup)
    ' Subroutine to enumerate members of local group.
    ' The variable strComputer has global scope.
 
    Dim objMember
 
    ' Enumerate direct members of group.
    For Each objMember In objGroup.Members
        Wscript.Echo objMember.AdsPath
        ' Test if member is a group.
        If (LCase(objMember.Class) = "group") Then
            ' Nested group. Test if objMember is a local group.
            If (InStr(LCase(objMember.AdsPath), "/" _
                    & LCase(strComputer) & "/") > 0) Then
                ' objMember is a local group.
                ' Call sub recursively to enumerate nested local group.
                Call EnumLocalGroup(objMember)
            Else
                ' objMember is a domain group.
                ' Call sub that uses LDAP provider to enumerate
                ' nested domain group. objMember is bound with
                ' WinNT provider.
                Call EnumDomainGroup(objMember, True)
            End If
        End If
    Next
 
End Sub
 
Sub EnumDomainGroup(ByVal objDomainGroup, ByVal blnNT)
    ' Subroutine to enumerate members of domain group.
    ' blnNT is True if objDomainGroup is bound with WinNT,
    ' False if bound with LDAP.
    ' The variables objTrans and strNetBIOSDomain have global scope.
 
    Dim strNTName, strGroupDN, objGroup, objMember
 
    ' Check if this function called before.
    If (IsEmpty(objTrans) = True) Then
        ' objDomainGroup must be bound with WinNT.
        ' Setup NameTranslate. Connect to Global Catalog.
        Set objTrans = CreateObject("NameTranslate")
        objTrans.Init ADS_NAME_INITTYPE_GC, ""
 
        ' Convert NetBIOS name of group to Distinguished Name.
        strNTName = strNetBIOSDomain & "\" & objDomainGroup.Name
        objTrans.Set ADS_NAME_TYPE_NT4, strNTName
        strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779)
        ' Escape any forward slash characters, "/", with the backslash
        ' escape character. All other characters that should be escaped are.
        strGroupDN = Replace(strGroupDN, "/", "\/")
    Else
        ' NameTranslate already setup. Check if objDomainGroup
        ' bound with WinNT.
        If (blnNT = True) Then
            ' Convert NetBIOS name of group to Distinguished Name.
            strNTName = strNetBIOSDomain & "\" & objDomainGroup.Name
            objTrans.Set ADS_NAME_TYPE_NT4, strNTName
            strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779)
            ' Escape any forward slash characters, "/", with the backslash
            ' escape character. All other characters that should be escaped are.
            strGroupDN = Replace(strGroupDN, "/", "\/")
        Else
            ' objDomainGroup bound with LDAP. Retrieve Distinguished Name.
            strGroupDN = objDomainGroup.distinguishedName
            ' Escape any forward slash characters, "/", with the backslash
            ' escape character. All other characters that should be escaped are.
            strGroupDN = Replace(strGroupDN, "/", "\/")
        End If
    End If
    ' Bind to group with the LDAP provider, if required.
    If (blnNT = True) Then
        Set objGroup = GetObject("LDAP://" & strGroupDN)
    Else
        Set objGroup = objDomainGroup
    End If
    ' Enumerate direct members of objDomainGroup (bound with LDAP).
    For Each objMember In objGroup.Members
        Wscript.Echo objMember.AdsPath
        ' Check if objMember is a group.
        If (LCase(objMember.Class) = "group") Then
            ' Call sub recursively. objMember bound with LDAP.
            Call EnumDomainGroup(objMember, False)
        End If
    Next
 
End Sub
[+][-]05.20.2008 at 02:47PM PDT, ID: 21610663

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 02:59PM PDT, ID: 21610739

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 06:46PM PDT, ID: 21611627

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 07:18PM PDT, ID: 21611749

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 05:02AM PDT, ID: 21614079

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 11:50PM PDT, ID: 21629879

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Windows 2003 Server, Scripting Languages
Tags: Microsoft, vbscript
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.27.2008 at 03:00PM PDT, ID: 21656125

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628