<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vbscriptblog.com &#187; distributiongroups</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/active-directory/distributiongroups/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbscriptblog.com</link>
	<description>Scripting for Windows Sysadmins</description>
	<lastBuildDate>Mon, 16 Jan 2012 09:41:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Active Directory: VBscript to enumerate all distribution groups that are hidden in the Global Address List</title>
		<link>http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 06:48:58 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[active directory]]></category>
		<category><![CDATA[distributiongroups]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=670</guid>
		<description><![CDATA[The next script for today enumerates all hidden distribution groups. This is done by an ADO query with a filter on groups, msExchHideFromAddressLists and mail property. Follow the next steps to run the script (no admin rights needed): copy and paste the script in your favorite text editor save the script (for example c:temphidden-distribution-groups.vbs) open [...]]]></description>
			<content:encoded><![CDATA[<p>The next script for today enumerates all hidden distribution groups.<br />
This is done by an ADO query with a filter on groups, msExchHideFromAddressLists and mail property.  </p>
<p>Follow the next steps to run the script  (no admin rights needed):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:temphidden-distribution-groups.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript hidden-distribution-groups.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : hidden-distribution-groups.vbs
' Description : script to enumerate all distribution groups that are hidden in the Global Address List
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 15-07-2010
' Level: intermediate

Set adoCommand = CreateObject(&quot;ADODB.Command&quot;)
Set adoConnection = CreateObject(&quot;ADODB.Connection&quot;)
adoConnection.Provider = &quot;ADsDSOObject&quot;
adoConnection.Open &quot;Active Directory Provider&quot;
adoCommand.ActiveConnection = adoConnection

Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
strBase = &quot;&lt;LDAP://&quot; &amp; objRootDSE.Get(&quot;defaultNamingContext&quot;) &amp; &quot;&gt;&quot;
strFilter = &quot;(&amp;(objectCategory=group)(msExchHideFromAddressLists=TRUE)(mail=*))&quot;
strAttributes = &quot;displayname, mail, msExchHideFromAddressLists&quot;

strQuery = strBase &amp; &quot;;&quot; &amp; strFilter &amp; &quot;;&quot; &amp; strAttributes &amp; &quot;;subtree&quot;
adoCommand.CommandText = strQuery
adoCommand.Properties(&quot;Page Size&quot;) = 100
adoCommand.Properties(&quot;Timeout&quot;) = 30
adoCommand.Properties(&quot;Cache Results&quot;) = False

Set objRecordset = adoCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
	Wscript.Echo objRecordSet.Fields(&quot;displayname&quot;).Value &amp; &quot; ; &quot; &amp; objRecordSet.Fields(&quot;mail&quot;).Value
	objRecordSet.MoveNext
Loop

Set objRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
</pre>
<p>When you have problems/questions please post a reply or give a &#8216;star&#8217; rating.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV </p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/"  data-text="Active Directory: VBscript to enumerate all distribution groups that are hidden in the Global Address List" data-count="horizontal" data-via="dirkadamsky">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory-vbscript-to-enumerate-all-distribution-groups-that-are-hidden-in-the-global-addres-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to count the number of users in subgroups of a nested distribution group</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 08:01:12 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[distributiongroups]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[members]]></category>
		<category><![CDATA[memberships]]></category>
		<category><![CDATA[nested group]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=469</guid>
		<description><![CDATA[Last friday I got a question from Marten on the number of users that a subgroup contains. I have made a small mutation of the previous script to achieve this. The output of the script now contains the number of users in each subgroup. Follow the next steps to run the script (no admin rights [...]]]></description>
			<content:encoded><![CDATA[<p>Last friday I got a question from Marten on the number of users that a subgroup contains.<br />
I have made a small mutation of the <a href="http://deludi.nl/blog/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/">previous script</a> to achieve this. The output of the script now contains the number of users in each subgroup.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<ul>
<li>open your favorite text editor</li>
<li>copy and paste the script into the editor</li>
<li> save the script (for example c:tempcountgroupmembershipnestedgroup.vbs)</li>
<li> open a command prompt</li>
<li> go to &#8220;c:temp&#8221;</li>
<li> give &#8220;cscript countgroupmembershipnestedgroup.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : countgroupmembershipnestedgroup.vbs
' Description : script to count the number of users in subgroups of a nested distribution group
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 30-03-2010
' Level : intermediate

Set objDictionary = CreateObject(&quot;Scripting.Dictionary&quot;)
strTargetGroupDN = &quot;LDAP://CN=SW (Alle Medewerkers),OU=DistributieGroepen,OU=Groepen,DC=domstad,DC=org&quot;
Call EnumNestedgroup(strTargetGroupDN)

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			If objDictionary.Exists(objGroup.DisplayName) Then
				objDictionary.Item(objGroup.DisplayName) = objDictionary.Item(objGroup.DisplayName) + 1
			Else
				objDictionary.Add objGroup.DisplayName, 1
			End If
		End If
	Next
	Set objGroup = Nothing
End Sub

For Each strKey in objDictionary.Keys
	If objDictionary.Item(strKey) &gt; 1 Then
		Wscript.Echo strKey &amp; &quot; contains ; &quot; &amp; objDictionary.Item(strKey) &amp; &quot; ; users&quot;
	End If
Next

Set objDictionary = Nothing
</pre>
<p>When you have problems/questions please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky &#8211; Deludi BV<br />
[adrotate group="1"] </p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Fdistributiongroups%2Factive-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/"  data-text="Active Directory: VBscript to count the number of users in subgroups of a nested distribution group" data-count="horizontal" data-via="dirkadamsky">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-the-number-of-users-in-subgroups-of-a-nested-distribution-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to count users with multiple entries in a nested distribution group</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 13:20:13 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[distributiongroups]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[distribution group]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[homedirectory]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[memberships]]></category>
		<category><![CDATA[nested group]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=302</guid>
		<description><![CDATA[This script is something I wanted to do for a long time It is a mutation of the enumeratenestedgroupV2 script. In large organizations the main distributiongroups tend to be complex also. Often the distributiongroups represent the organization hierarchy. A user in general only needs his/her department distributiongroup membership. This script checks If a user has [...]]]></description>
			<content:encoded><![CDATA[<p>This script is something I wanted to do for a long time<br />
It is a mutation of the  <a href="http://deludi.nl/blog/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-the-members-of-nested-groups-v2/">enumeratenestedgroupV2</a> script.<br />
In large organizations the main distributiongroups tend to be complex also.<br />
Often the distributiongroups represent the organization hierarchy.<br />
A user in general only needs his/her department distributiongroup membership.<br />
This script checks If a user has multiple entries in the main distributiongroup, if so an entry is added to the output.<br />
Part of the script is the use of the dictionary object, also known as &#8220;associative array&#8221; in other scripting languages.</p>
<p>What the script does:</p>
<ul>
<li>create a dictionary object</li>
<li>fill a variable with the group distinguished name</li>
<li>call the subroutine EnumNestedgroup</li>
<li>the subroutine checks whether the member is a group or a user</li>
<li>when the member is a user the smtp address is added to the dictionary object with value 1</li>
<li>when the smtp address is already in the dictionary 1 is added to the value</li>
<li>the last routine echoes the dictionary object keys and values</li>
</ul>
<p>Follow the next steps to run the script  (no admin rights needed):</p>
<ul>
<li>find the distinguished name of the nested group (adsiedit.msc)</li>
<li>open your favorite text editor</li>
<li>copy and paste the script into the editor</li>
<li>change the distinguished name</li>
<li>save the script (for example c:tempcountmembershipnestedgroup.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript enumeratenestedgroup.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : countmembershipnestedgroup.vbs
' Description : script to count users with multiple entries in a nested distribution group
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 16-02-2010
' Level : advanced

Set objDictionary = CreateObject(&quot;Scripting.Dictionary&quot;)
strTargetGroupDN = &quot;LDAP://CN=testgroup,OU=groups,DC=test,DC=org&quot;
Call EnumNestedgroup(strTargetGroupDN)

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			If objDictionary.Exists(objMember.DisplayName) Then
				objDictionary.Item(objMember.DisplayName) = objDictionary.Item(objMember.DisplayName) + 1
			Else
				objDictionary.Add objMember.DisplayName, 1
			End If
		End If
	Next
	Set objGroup = Nothing
End Sub

For Each strKey in objDictionary.Keys
	If objDictionary.Item(strKey) &gt; 1 Then
		Wscript.Echo strKey &amp; &quot; ; &quot; &amp; objDictionary.Item(strKey) &amp; &quot; ; entries in list&quot;
	End If
Next

Set objDictionary = Nothing
</pre>
<p>When you have problems/questions please post a reply.</p>
<p>Happy scripting.</p>
<p>Dirk Adamsky &#8211; Deludi BV</p>
<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fvbscriptblog.com%2Fvbscript%2Factive-directory%2Fdistributiongroups%2Factive-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/"  data-text="Active Directory: VBscript to count users with multiple entries in a nested distribution group" data-count="horizontal" data-via="dirkadamsky">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/distributiongroups/active-directory-vbscript-to-count-users-with-multiple-entries-in-a-nested-distribution-group/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

