HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Windows Server 2003
- >
- Re: AD Script to search and list members
Windows Server 2003
1833032
Members
2395
Online
110049
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2009 04:49 AM
05-05-2009 04:49 AM
AD Script to search and list members
Hi,
We have 100+ groups in our Active Directory. Iam trying to write an script which will prompt the user for an group name to be searched inside the AD and then displays the members of the group ? Can this be achieved by script? If so can someone please help.
Regards
RVK
We have 100+ groups in our Active Directory. Iam trying to write an script which will prompt the user for an group name to be searched inside the AD and then displays the members of the group ? Can this be achieved by script? If so can someone please help.
Regards
RVK
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2009 04:56 PM
05-05-2009 04:56 PM
Re: AD Script to search and list members
Gday,
Yes relatively easy to do (via ADSI - could also look at powershell) depends upon ou's or whatever and how you have layed out your Active Directory. There are two ways use WinNT provider (may be problematic if AD is running Win2003 Native Mode) or LDAP provider. Here is some simple code which can be built upon.
WinNT:
cut below into file called script.vbs put in your domain controller and test group and run - cscript script.vbs
--------------------------
agroup = ""
aserver = ""
set x = getobject("WinNT://" & aserver & "/" & agroup & ",group")
for each entry in x.members
if ucase(entry.class) = "USER" then
wscript.echo entry.name
end if
next
set x = nothing
--------------------------
LDAP:
Unfortunately LDAP requires precise location of group (eg: ou=sales,dc=microsoft,dc=com or cn=groups, dc=microsoft, dc=com). Your dns forest/domain name make up the DC aspect of the lookup thus server1.yahoo.com.au is server1=dc,dc=yahoo, dc=com, dc=au etc.
If you have different OUs such as SALES, HR etc and groups within that then you have
cn=yourgroup, ou=SALES, dc=
or
cn=yourgroup, ou=HR, dc=
Then you can do a similar thing as above but use LDAP instead of WinNT.
--------------
agroup = "cn=,ou=sales"
adomain = "dc=yahoo,dc=com,dc=au"
aserver = ""
set x = getobject("LDAP://" & aserver & "/" & agroup & "," & adomain)
for each entry in x.members
if entry.class = "User" then
wscript.echo entry.samaccountname
end if
next
set x = nothing
----------------
Yes relatively easy to do (via ADSI - could also look at powershell) depends upon ou's or whatever and how you have layed out your Active Directory. There are two ways use WinNT provider (may be problematic if AD is running Win2003 Native Mode) or LDAP provider. Here is some simple code which can be built upon.
WinNT:
cut below into file called script.vbs put in your domain controller and test group and run - cscript script.vbs
--------------------------
agroup = "
aserver = "
set x = getobject("WinNT://" & aserver & "/" & agroup & ",group")
for each entry in x.members
if ucase(entry.class) = "USER" then
wscript.echo entry.name
end if
next
set x = nothing
--------------------------
LDAP:
Unfortunately LDAP requires precise location of group (eg: ou=sales,dc=microsoft,dc=com or cn=groups, dc=microsoft, dc=com). Your dns forest/domain name make up the DC aspect of the lookup thus server1.yahoo.com.au is server1=dc,dc=yahoo, dc=com, dc=au etc.
If you have different OUs such as SALES, HR etc and groups within that then you have
cn=yourgroup, ou=SALES, dc=
or
cn=yourgroup, ou=HR, dc=
Then you can do a similar thing as above but use LDAP instead of WinNT.
--------------
agroup = "cn=
adomain = "dc=yahoo,dc=com,dc=au"
aserver = "
set x = getobject("LDAP://" & aserver & "/" & agroup & "," & adomain)
for each entry in x.members
if entry.class = "User" then
wscript.echo entry.samaccountname
end if
next
set x = nothing
----------------
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP