VB script to get the group name's description in Active Directory

Posted on 2008-06-24
Last Modified: 2008-10-14
With the following code I can get the groups that belong to an OU. Now I would like to add some code to the one below so I can get the group's description. Any help will be very much appreciated.

strGroupDN = "GroupDN"
strSpaces = ""
set dicSeenGroupMember = CreateObject("Scripting.Dictionary")
Wscript.Echo "GROUP:"
Wscript.Echo ""
Wscript.Echo "MEMBERS:"
DisplayMembers "LDAP://" & strGroupDN, strSpaces, dicSeenGroupMember
Function DisplayMembers (strGroupADsPath, strSpaces, dicSeenGroupMember)
set objGroup = GetObject(strGroupADsPath)
for each objMember In objGroup.Members
Wscript.Echo strSpaces & objMember.Name
if objMember.Class = "group" then
if dicSeenGroupMember.Exists(objMember.ADsPath) then
Wscript.Echo strSpaces & "already seen group member" & _
"(stopping to avoid loop)"
dicSeenGroupMember.Add objMember.ADsPath, 1
DisplayMembers objMember.ADsPath, strSpaces & "  " , _
end if
end if
End Function
Question by:kt2003
  • 3
  • 2
LVL 28

Expert Comment

Comment Utility

OM Gang

Author Comment

Comment Utility
omgang. Thank you for your quick response. I don't know much about VB script. Could you please write some code.
LVL 28

Accepted Solution

omgang earned 500 total points
Comment Utility
Outputs Group name, Group e-mail addy & Group Description
OM Gang
Option Explicit

Dim strMember, strDNSDomain, strContainer, strPath, strFileName

Dim objGroup, objRootDSE, objParentOU, objFSO, objFile

Dim arrMemberOf

strContainer = "OU=Groups,OU=IT, "

Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("DefaultNamingContext")

strPath = "C:\temp\"

strFileName = Trim(strContainer) & ".txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.CreateTextFile(strPath & strFileName)

Set objParentOU = GetObject("LDAP://"& strContainer & strDNSDomain)

objParentOU.Filter = Array("Group")

For Each objGroup in objParentOU

      objFile.WriteLine objGroup.CN & "|" & objGroup.Mail & "|" & objGroup.Description


WScript.echo "Completed.  See output file " & strPath & strFileName



Set objFile = Nothing

Set objGroup = Nothing

Set objParentOU = Nothing

Set objFSO = Nothing

Set objRootDSE = Nothing

Open in new window


Author Comment

Comment Utility
omgang, could please integrate the objGroup.Description with the code that I wrote? Many thanks in advance.

Author Comment

Comment Utility
omgang. It is ok. I have already changed the script and it is working.
Thank you.

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature ( The script is fine, and works in normal client-server domains…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now