Home All Groups Group Topic Archive Search About

List Users and Attributes in Multiple Groups



Author
25 Sep 2007 5:56 PM
DSchenk952
Hi, I'm relatively new to scripting and have run a search to find a script
that will let me feed it a list of AD Groups and extract attributes for all
the users in the groups.  I have a small script that will let me retrieve the
LDAP name, but would also like to extract things like LANID, Display Name,
Group Name, EmployeeID in a table that I can sort.

I'll continue my search but I thought I would post here to see what may be
available untill I find something.

Thanks,
--
Don S

Author
25 Sep 2007 8:19 PM
JakeDAHS
On Sep 25, 1:56 pm, DSchenk952 <DSchenk***@discussions.microsoft.com>
wrote:
> Hi, I'm relatively new to scripting and have run a search to find a script
> that will let me feed it a list of AD Groups and extract attributes for all
> the users in the groups.  I have a small script that will let me retrieve the
> LDAP name, but would also like to extract things like LANID, Display Name,
> Group Name, EmployeeID in a table that I can sort.
>
> I'll continue my search but I thought I would post here to see what may be
> available untill I find something.
>
> Thanks,
> --
> Don S

Don,

Can you post the script you're currently using?

-J
www.pooradmin.com
Author
25 Sep 2007 8:46 PM
DSchenk952
In this script I'm getting the group member LDAP name back, (if I'm saying
that correctly).  And would like the output on LANID, GroupName, EmployeeID,
etc.,

===============================

On Error Resume Next

Set objGroup = GetObject _
  ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

WScript.Echo "Forest Owners"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

Set objGroup = GetObject _
  ("LDAP://cn= Service Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

WScript.Echo ""
WScript.Echo "Service Admins"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

Set objGroup = GetObject _
  ("LDAP://cn=Data Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")
WScript.Echo ""
WScript.Echo "Data Admins"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

Set objGroup = GetObject _
  ("LDAP://cn=ServiceDesk Operators,ou=Global
Admins,dc=Don,dc=Corvette,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")
WScript.Echo ""
WScript.Echo "ServiceDesk Operators"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

Set objGroup = GetObject _
  ("LDAP://cn=IT_DBA,ou=Server Admins,ou=Servers,dc=Don,dc=Corvette,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")
WScript.Echo ""
WScript.Echo "IT_DBA"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

==============================
--
Don S


Show quote
"JakeDAHS" wrote:

> On Sep 25, 1:56 pm, DSchenk952 <DSchenk***@discussions.microsoft.com>
> wrote:
> > Hi, I'm relatively new to scripting and have run a search to find a script
> > that will let me feed it a list of AD Groups and extract attributes for all
> > the users in the groups.  I have a small script that will let me retrieve the
> > LDAP name, but would also like to extract things like LANID, Display Name,
> > Group Name, EmployeeID in a table that I can sort.
> >
> > I'll continue my search but I thought I would post here to see what may be
> > available untill I find something.
> >
> > Thanks,
> > --
> > Don S
>
> Don,
>
> Can you post the script you're currently using?
>
> -J
> www.pooradmin.com
>
>
Author
25 Sep 2007 9:40 PM
Richard Mueller [MVP]
I suggest using the Members method of the group object, which returns a
collection of member objects. With the member objects you can retrieve any
attribute values desired. For example:
===========
Set objGroup = GetObject _
    ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
For Each objMember In objGroup.Members
    Wscript.Echo objMember.sAMAccountName & "," & objGroup.sAMAccountName &
"," & objMember.employeeID
Next
=========
The code you posted displays the member Distinguished Names. The
sAMAccountName attribute is the "pre-Windows logon name" of users, and is
probably what you call LANID (some call it userID or NT User name). The
sAMAccountName attribute of group objects is the NetBIOS name of the group.
You could substitute the Common Name of the group with objGroup.cn. The
Distinguished Name of the user would be objUser.distinguishedName.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

Show quote
"DSchenk952" <DSchenk***@discussions.microsoft.com> wrote in message
news:344531E2-DEC0-4539-A81D-3344F7BB85A1@microsoft.com...
> In this script I'm getting the group member LDAP name back, (if I'm saying
> that correctly).  And would like the output on LANID, GroupName,
> EmployeeID,
> etc.,
>
> ===============================
>
> On Error Resume Next
>
> Set objGroup = GetObject _
>  ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
>
> WScript.Echo "Forest Owners"
> For Each strMember in arrMemberOf
>    WScript.echo strMember
> Next
>
> Set objGroup = GetObject _
>  ("LDAP://cn= Service Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
>
> WScript.Echo ""
> WScript.Echo "Service Admins"
> For Each strMember in arrMemberOf
>    WScript.echo strMember
> Next
>
> Set objGroup = GetObject _
>  ("LDAP://cn=Data Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
> WScript.Echo ""
> WScript.Echo "Data Admins"
> For Each strMember in arrMemberOf
>    WScript.echo strMember
> Next
>
> Set objGroup = GetObject _
>  ("LDAP://cn=ServiceDesk Operators,ou=Global
> Admins,dc=Don,dc=Corvette,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
> WScript.Echo ""
> WScript.Echo "ServiceDesk Operators"
> For Each strMember in arrMemberOf
>    WScript.echo strMember
> Next
>
> Set objGroup = GetObject _
>  ("LDAP://cn=IT_DBA,ou=Server
> Admins,ou=Servers,dc=Don,dc=Corvette,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
> WScript.Echo ""
> WScript.Echo "IT_DBA"
> For Each strMember in arrMemberOf
>    WScript.echo strMember
> Next
>
> ==============================
> --
> Don S
>
>
> "JakeDAHS" wrote:
>
>> On Sep 25, 1:56 pm, DSchenk952 <DSchenk***@discussions.microsoft.com>
>> wrote:
>> > Hi, I'm relatively new to scripting and have run a search to find a
>> > script
>> > that will let me feed it a list of AD Groups and extract attributes for
>> > all
>> > the users in the groups.  I have a small script that will let me
>> > retrieve the
>> > LDAP name, but would also like to extract things like LANID, Display
>> > Name,
>> > Group Name, EmployeeID in a table that I can sort.
>> >
>> > I'll continue my search but I thought I would post here to see what may
>> > be
>> > available untill I find something.
>> >
>> > Thanks,
>> > --
>> > Don S
>>
>> Don,
>>
>> Can you post the script you're currently using?
>>
>> -J
>> www.pooradmin.com
>>
>>
Author
25 Sep 2007 11:58 PM
DSchenk952
Richard,

Thanks.  That's great, and does exactly what I'm looking for.  Only one more
question from this noobie.  Where can I find the different values that go
along with objMember?

Thanks, I appreciate the schooling.
--
Don S


Show quote
"Richard Mueller [MVP]" wrote:

> I suggest using the Members method of the group object, which returns a
> collection of member objects. With the member objects you can retrieve any
> attribute values desired. For example:
> ===========
> Set objGroup = GetObject _
>     ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> For Each objMember In objGroup.Members
>     Wscript.Echo objMember.sAMAccountName & "," & objGroup.sAMAccountName &
> "," & objMember.employeeID
> Next
> =========
> The code you posted displays the member Distinguished Names. The
> sAMAccountName attribute is the "pre-Windows logon name" of users, and is
> probably what you call LANID (some call it userID or NT User name). The
> sAMAccountName attribute of group objects is the NetBIOS name of the group.
> You could substitute the Common Name of the group with objGroup.cn. The
> Distinguished Name of the user would be objUser.distinguishedName.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "DSchenk952" <DSchenk***@discussions.microsoft.com> wrote in message
> news:344531E2-DEC0-4539-A81D-3344F7BB85A1@microsoft.com...
> > In this script I'm getting the group member LDAP name back, (if I'm saying
> > that correctly).  And would like the output on LANID, GroupName,
> > EmployeeID,
> > etc.,
> >
> > ===============================
> >
> > On Error Resume Next
> >
> > Set objGroup = GetObject _
> >  ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> > objGroup.GetInfo
> >
> > arrMemberOf = objGroup.GetEx("member")
> >
> > WScript.Echo "Forest Owners"
> > For Each strMember in arrMemberOf
> >    WScript.echo strMember
> > Next
> >
> > Set objGroup = GetObject _
> >  ("LDAP://cn= Service Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> > objGroup.GetInfo
> >
> > arrMemberOf = objGroup.GetEx("member")
> >
> > WScript.Echo ""
> > WScript.Echo "Service Admins"
> > For Each strMember in arrMemberOf
> >    WScript.echo strMember
> > Next
> >
> > Set objGroup = GetObject _
> >  ("LDAP://cn=Data Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
> > objGroup.GetInfo
> >
> > arrMemberOf = objGroup.GetEx("member")
> > WScript.Echo ""
> > WScript.Echo "Data Admins"
> > For Each strMember in arrMemberOf
> >    WScript.echo strMember
> > Next
> >
> > Set objGroup = GetObject _
> >  ("LDAP://cn=ServiceDesk Operators,ou=Global
> > Admins,dc=Don,dc=Corvette,dc=com")
> > objGroup.GetInfo
> >
> > arrMemberOf = objGroup.GetEx("member")
> > WScript.Echo ""
> > WScript.Echo "ServiceDesk Operators"
> > For Each strMember in arrMemberOf
> >    WScript.echo strMember
> > Next
> >
> > Set objGroup = GetObject _
> >  ("LDAP://cn=IT_DBA,ou=Server
> > Admins,ou=Servers,dc=Don,dc=Corvette,dc=com")
> > objGroup.GetInfo
> >
> > arrMemberOf = objGroup.GetEx("member")
> > WScript.Echo ""
> > WScript.Echo "IT_DBA"
> > For Each strMember in arrMemberOf
> >    WScript.echo strMember
> > Next
> >
> > ==============================
> > --
> > Don S
> >
> >
> > "JakeDAHS" wrote:
> >
> >> On Sep 25, 1:56 pm, DSchenk952 <DSchenk***@discussions.microsoft.com>
> >> wrote:
> >> > Hi, I'm relatively new to scripting and have run a search to find a
> >> > script
> >> > that will let me feed it a list of AD Groups and extract attributes for
> >> > all
> >> > the users in the groups.  I have a small script that will let me
> >> > retrieve the
> >> > LDAP name, but would also like to extract things like LANID, Display
> >> > Name,
> >> > Group Name, EmployeeID in a table that I can sort.
> >> >
> >> > I'll continue my search but I thought I would post here to see what may
> >> > be
> >> > available untill I find something.
> >> >
> >> > Thanks,
> >> > --
> >> > Don S
> >>
> >> Don,
> >>
> >> Can you post the script you're currently using?
> >>
> >> -J
> >> www.pooradmin.com
> >>
> >>
>
>
>
Author
26 Sep 2007 1:43 AM
Richard Mueller [MVP]
There are many attributes available. This link documents most:

http://www.rlmueller.net/UserAttributes.htm

The first spreadsheet documents the user attributes corresponding to most of
the tabs in ADUC. The second spreadsheet documents all attributes in a
default installation of Windows 2000 AD, and the classes of objects they
apply to (user, group, computer, etc). The third spreadsheet documents user
object methods available.

Note that objMember can be a user, a group, or a computer object.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

Show quote
"DSchenk952" <DSchenk***@discussions.microsoft.com> wrote in message
news:E3685C41-2120-4E06-B03B-6BC81230B616@microsoft.com...
> Richard,
>
> Thanks.  That's great, and does exactly what I'm looking for.  Only one
> more
> question from this noobie.  Where can I find the different values that go
> along with objMember?
>
> Thanks, I appreciate the schooling.
> --
> Don S
>
>
> "Richard Mueller [MVP]" wrote:
>
>> I suggest using the Members method of the group object, which returns a
>> collection of member objects. With the member objects you can retrieve
>> any
>> attribute values desired. For example:
>> ===========
>> Set objGroup = GetObject _
>>     ("LDAP://cn=Forest Owners,ou=Global
>> Admins,dc=Don,dc=Corvette,dc=com")
>> For Each objMember In objGroup.Members
>>     Wscript.Echo objMember.sAMAccountName & "," & objGroup.sAMAccountName
>> &
>> "," & objMember.employeeID
>> Next
>> =========
>> The code you posted displays the member Distinguished Names. The
>> sAMAccountName attribute is the "pre-Windows logon name" of users, and is
>> probably what you call LANID (some call it userID or NT User name). The
>> sAMAccountName attribute of group objects is the NetBIOS name of the
>> group.
>> You could substitute the Common Name of the group with objGroup.cn. The
>> Distinguished Name of the user would be objUser.distinguishedName.
>>
>> --
>> Richard Mueller
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab - http://www.rlmueller.net
>> --
>>
>> "DSchenk952" <DSchenk***@discussions.microsoft.com> wrote in message
>> news:344531E2-DEC0-4539-A81D-3344F7BB85A1@microsoft.com...
>> > In this script I'm getting the group member LDAP name back, (if I'm
>> > saying
>> > that correctly).  And would like the output on LANID, GroupName,
>> > EmployeeID,
>> > etc.,
>> >
>> > ===============================
>> >
>> > On Error Resume Next
>> >
>> > Set objGroup = GetObject _
>> >  ("LDAP://cn=Forest Owners,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
>> > objGroup.GetInfo
>> >
>> > arrMemberOf = objGroup.GetEx("member")
>> >
>> > WScript.Echo "Forest Owners"
>> > For Each strMember in arrMemberOf
>> >    WScript.echo strMember
>> > Next
>> >
>> > Set objGroup = GetObject _
>> >  ("LDAP://cn= Service Admins,ou=Global
>> > Admins,dc=Don,dc=Corvette,dc=com")
>> > objGroup.GetInfo
>> >
>> > arrMemberOf = objGroup.GetEx("member")
>> >
>> > WScript.Echo ""
>> > WScript.Echo "Service Admins"
>> > For Each strMember in arrMemberOf
>> >    WScript.echo strMember
>> > Next
>> >
>> > Set objGroup = GetObject _
>> >  ("LDAP://cn=Data Admins,ou=Global Admins,dc=Don,dc=Corvette,dc=com")
>> > objGroup.GetInfo
>> >
>> > arrMemberOf = objGroup.GetEx("member")
>> > WScript.Echo ""
>> > WScript.Echo "Data Admins"
>> > For Each strMember in arrMemberOf
>> >    WScript.echo strMember
>> > Next
>> >
>> > Set objGroup = GetObject _
>> >  ("LDAP://cn=ServiceDesk Operators,ou=Global
>> > Admins,dc=Don,dc=Corvette,dc=com")
>> > objGroup.GetInfo
>> >
>> > arrMemberOf = objGroup.GetEx("member")
>> > WScript.Echo ""
>> > WScript.Echo "ServiceDesk Operators"
>> > For Each strMember in arrMemberOf
>> >    WScript.echo strMember
>> > Next
>> >
>> > Set objGroup = GetObject _
>> >  ("LDAP://cn=IT_DBA,ou=Server
>> > Admins,ou=Servers,dc=Don,dc=Corvette,dc=com")
>> > objGroup.GetInfo
>> >
>> > arrMemberOf = objGroup.GetEx("member")
>> > WScript.Echo ""
>> > WScript.Echo "IT_DBA"
>> > For Each strMember in arrMemberOf
>> >    WScript.echo strMember
>> > Next
>> >
>> > ==============================
>> > --
>> > Don S
>> >
>> >
>> > "JakeDAHS" wrote:
>> >
>> >> On Sep 25, 1:56 pm, DSchenk952 <DSchenk***@discussions.microsoft.com>
>> >> wrote:
>> >> > Hi, I'm relatively new to scripting and have run a search to find a
>> >> > script
>> >> > that will let me feed it a list of AD Groups and extract attributes
>> >> > for
>> >> > all
>> >> > the users in the groups.  I have a small script that will let me
>> >> > retrieve the
>> >> > LDAP name, but would also like to extract things like LANID, Display
>> >> > Name,
>> >> > Group Name, EmployeeID in a table that I can sort.
>> >> >
>> >> > I'll continue my search but I thought I would post here to see what
>> >> > may
>> >> > be
>> >> > available untill I find something.
>> >> >
>> >> > Thanks,
>> >> > --
>> >> > Don S
>> >>
>> >> Don,
>> >>
>> >> Can you post the script you're currently using?
>> >>
>> >> -J
>> >> www.pooradmin.com
>> >>
>> >>
>>
>>
>>

AddThis Social Bookmark Button