Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-24
5
Medium Priority
?
1,815 Views
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)"
else
dicSeenGroupMember.Add objMember.ADsPath, 1
DisplayMembers objMember.ADsPath, strSpaces & "  " , _
dicSeenGroupMember
end if
end if
next
End Function
0
Comment
Question by:kt2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 21856481
objGroup.Description

OM Gang
0
 

Author Comment

by:kt2003
ID: 21856524
omgang. Thank you for your quick response. I don't know much about VB script. Could you please write some code.
0
 
LVL 28

Accepted Solution

by:
omgang earned 1500 total points
ID: 21856547
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
Next
 
WScript.echo "Completed.  See output file " & strPath & strFileName
 
WScript.Quit
 
objFile.Close
 
Set objFile = Nothing
Set objGroup = Nothing
Set objParentOU = Nothing
Set objFSO = Nothing
Set objRootDSE = Nothing

Open in new window

0
 

Author Comment

by:kt2003
ID: 21856657
omgang, could please integrate the objGroup.Description with the code that I wrote? Many thanks in advance.
0
 

Author Comment

by:kt2003
ID: 21856902
omgang. It is ok. I have already changed the script and it is working.
Thank you.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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