<?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; smtp address</title>
	<atom:link href="http://vbscriptblog.com/tag/smtp-address/feed/" rel="self" type="application/rss+xml" />
	<link>http://vbscriptblog.com</link>
	<description>Scripting for Windows Sysadmins</description>
	<lastBuildDate>Wed, 11 Apr 2012 07:23:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>VBscript to enumerate the home directories and their sizes of all users in Active Directory V2</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 14:03:59 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[home directories]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[homedirectory]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://vbscriptblog.com/?p=1257</guid>
		<description><![CDATA[This is a better version of my previous script to enumerate the home directory sizes of all active directory users. The problem with the previous one was that some home directory sizes were not calculated because the Filesystem object had difficulties with long pathnames. I did a search for a WMI based solution but unfortunately [...]]]></description>
			<content:encoded><![CDATA[<p>This is a better version of my <a href="http://vbscriptblog.com/vbscript/active-directory/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/">previous script to enumerate the home directory sizes of all active directory users</a>. The problem with the previous one was that some home directory sizes were not calculated because the Filesystem object had difficulties with <a href="http://msdn.microsoft.com/en-us/library/ms165768.aspx">long pathnames</a>.<br />
I did a search for a WMI based solution but unfortunately i could not find one.<br />
To shorten the UNC path i decided to create a drive mapping with the Wscript Network object.<br />
It&#8217;s a bit of a &#8220;funky solution&#8221; but it works.</p>
<p>Follow the next steps to run the script (admin rights needed for access to the home directories):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* save the script (for example c:\temp\homedirectorysizev2.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript homedirectorysizev2.vbs&#8221; (without quotes) and enter</p>
<p>Notes:<br />
1. when you run the script as administrator a h: network drive is created and disconnected for each user. When you want another drive letter you can change h: in the function to another drive letter.<br />
2. when you cancel the script before it is finished please manually disconnect the &#8220;h:&#8221; drive mapping</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : homedirectorysizev2.vbs
' Description : script to enumerate the home directories and their sizes of all users in Active Directory v2
' Author : dirk adamsky - deludi bv
' Version : 2.00
' Date : 14-07-2011
' Level : intermediate

arrAttributes = Array(&quot;homeDirectory&quot;,&quot;displayname&quot;,&quot;mail&quot;)

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;
Set objRootDSE = Nothing

strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(homeDirectory=*))&quot;
strAttributes = Join(arrAttributes,&quot;,&quot;)
Wscript.Echo Join(arrAttributes,&quot;;&quot;) &amp; &quot; ; home directory size in MB&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 adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
	On Error Resume Next
	strTempOutput = &quot;&quot;
	For i = 0 To Ubound(arrAttributes)
		strTempOutput =  strTempOutput &amp; &quot; ; &quot; &amp; adoRecordset.Fields(arrAttributes(i)).Value
		strOutput = Mid(Ltrim(strTempOutput),3)
	Next
	Wscript.Echo strOutput &amp; &quot; ; &quot; &amp; Foldersize (adoRecordset.Fields(arrAttributes(0)).Value) &amp; &quot; MB&quot;
	adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function Foldersize(strPath)
	On Error Resume Next
	Set objNetwork = CreateObject(&quot;WScript.Network&quot;)
	Set objFSO = CreateObject(&quot;scripting.filesystemobject&quot;)
	objNetwork.MapNetworkDrive &quot;h:&quot;, strPath
	Set objFld = objFSO.GetFolder(&quot;h:&quot;)
	Foldersize = Round(objFld.Size/1048576,2)
	objNetwork.RemoveNetworkDrive &quot;h:&quot;
	Set objFld = Nothing
	Set objFSO = Nothing
End Function
</pre>
<p>When you have problems/questions please post a reply. Also can also 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%2Fhome-directories%2Fvbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/"></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/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/"  data-text="VBscript to enumerate the home directories and their sizes of all users in Active Directory V2" data-count="horizontal" data-via="dirkadamsky"></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/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/home-directories/vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory-v2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the home directories and their sizes of all users in Active Directory</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 13:47:04 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[home directories]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filesystem object]]></category>
		<category><![CDATA[home directory]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://vbscriptblog.com/?p=1245</guid>
		<description><![CDATA[Update: This script has some issues (path not found) with users with very large home folders and or homefolders with long pathnames. This is due to limitations of the Filesystem Object. I will see if i can make a &#8220;better solution&#8221;. Dave asked me for a script to enumerate all AD users, their home directories [...]]]></description>
			<content:encoded><![CDATA[<p>Update: This script has some issues (path not found) with users with very large home folders and or homefolders with long pathnames. This is due to limitations of the Filesystem Object. I will see if i can make a &#8220;better solution&#8221;.</p>
<p>Dave asked me for a script to enumerate all AD users, their home directories and the size of them.<br />
I already had the script to do that for <a href="http://vbscriptblog.com/vbscript/active-directory/roamingprofile/active-directory-vbscript-to-enumerate-the-roaming-profile-size-of-all-users-in-active-directory/">roaming profiles</a>.<br />
This script is a modified version.</p>
<p>Follow the next steps to run the script (admin rights needed for access to the home directories):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* save the script (for example c:\temp\homedirectorysize.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript homedirectorysize.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : homedirectorysize.vbs
' Description : script to enumerate the home directories and their sizes of all users in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 12-07-2011
' Level : intermediate

arrAttributes = Array(&quot;homeDirectory&quot;,&quot;displayname&quot;,&quot;mail&quot;) 

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;
Set objRootDSE = Nothing

strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(homeDirectory=*))&quot;
strAttributes = Join(arrAttributes,&quot;,&quot;)
Wscript.Echo Join(arrAttributes,&quot;;&quot;) &amp; &quot; ; home directory size in MB&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 adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
	On Error Resume Next
	strTempOutput = &quot;&quot;
	For i = 0 To Ubound(arrAttributes)
		strTempOutput =  strTempOutput &amp; &quot; ; &quot; &amp; adoRecordset.Fields(arrAttributes(i)).Value
		strOutput = Mid(Ltrim(strTempOutput),3)
	Next
	Wscript.Echo strOutput &amp; &quot; ; &quot; &amp; Foldersize (adoRecordset.Fields(arrAttributes(0)).Value) &amp; &quot; MB&quot;
	adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function Foldersize(strPath)
	On Error Resume Next
	Set objFSO = CreateObject(&quot;scripting.filesystemobject&quot;)
	Set objFld = objFSO.GetFolder(strPath)
	Foldersize = Round(objFld.Size/1048576,2)
	Set objFld = Nothing
	Set objFSO = Nothing
End Function
</pre>
<p>When you have problems/questions please post a reply. Also can alo 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%2Fhome-directories%2Factive-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/"></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/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/"  data-text="Active Directory: VBscript to enumerate the home directories and their sizes of all users in Active Directory" data-count="horizontal" data-via="dirkadamsky"></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/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/home-directories/active-directory-vbscript-to-enumerate-the-home-directories-and-their-sizes-of-all-users-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Active Directory and WMI: VBscript to enumerate a sorted list of all mailboxes and their size in your AD domain</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/#comments</comments>
		<pubDate>Tue, 17 May 2011 12:35:48 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[email]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mailbox]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=1040</guid>
		<description><![CDATA[Today&#8217;s script is made for Gavin. It is an extension of my previous script to enumerate all Exchange mailboxes and their size. Gavin asked for a sorted list based on mailbox size. My first attempt was to use the VB Arraylist object (.Net needed on the script machine). Here&#8217;s an Arraylist example by Rob van [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s script is made for <a href="http://deludi.nl/blog/vbscript/active-directory/exchange-active-directory-vbscript/active-directory-and-wmi-vbscript-to-enumerate-all-mailboxes-and-their-size-of-your-ad-domain/">Gavin</a>.<br />
It is an extension of my previous script to enumerate all Exchange mailboxes and their size.<br />
Gavin asked for a sorted list based on mailbox size.</p>
<p>My first attempt was to use the VB Arraylist object (.Net needed on the script machine).<br />
Here&#8217;s an <a href="http://www.robvanderwoude.com/vbstech_data_arraylist.php">Arraylist example</a> by Rob van der Woude.<br />
The problem with the Arraylist object is that it is not made for sorting multi dimensional arrays.<br />
I can do some tricks by concatenating all values to a superstring.<br />
The problem is that sorting an Arraylist with superstrings will be next to impossible.</p>
<p>Luckily I found a better solution by using a <a href="http://sogeeky.blogspot.com/2006/08/vbscript-using-disconnected-recordset.html">disconnected recordset<br />
</a> (= a recordset without database connection).<br />
One thing to check is to use the <a href="http://www.w3schools.com/ado/prop_field_type.asp#datatypeenum">right datatype</a> for each variable.<br />
I declared the &#8220;size&#8221; variable as a &#8220;double precision floating point&#8221;.<br />
The other 2 were delared as &#8220;null-terminated character strings&#8221;.<br />
With the disconnected recordset you can do a lot of funky stuff like sorting, filtering and so on.<br />
I will certainly use the disconnected recordset object in new scripts.</p>
<p>I have tested the script in a large environment (~ 8500 mailboxes).<br />
It worked flawless (okay I had to test and modify it for half an hour or so).</p>
<p>What the script does:</p>
<ul>
<li>get all exchange servers from your AD domain</li>
<li>make a wmi connection to each server and create a list of the mailboxes and their size</li>
<li>put all values in a disconnected recordset, sort and output to the screen</li>
</ul>
<p>The script is tested in a win2003/exchange2003 environment.</p>
<p>Follow the next steps to run the script  (admin rights needed):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:tempsortedlistofallmailboxes.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript sortedlistofallmailboxes.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : sortedlistofallmailboxes.vbs
' Description : script to enumerate all mailboxes and their size in your AD domain
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 17-05-2011
' Level: intermediate

Set DataList = CreateObject(&quot;ADOR.Recordset&quot;)
DataList.Fields.Append &quot;Servername&quot;, 200, 255
DataList.Fields.Append &quot;DisplayName&quot;, 200, 255
DataList.Fields.Append &quot;Size&quot;, 5
DataList.Open

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;configurationnamingcontext&quot;) &amp; &quot;&gt;&quot;
strFilter = &quot;(objectCategory=msExchExchangeServer)&quot;
strAttributes = &quot;name&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;) = 3
adoCommand.Properties(&quot;Cache Results&quot;) = False

Set adoRecordset = adoCommand.Execute

Do Until adoRecordset.EOF
 Set objWMIExchange = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!//&quot;&amp;_
 adoRecordset.Fields(&quot;name&quot;).Value &amp; &quot;/root/MicrosoftExchangeV2&quot;)
 Set colExchangeMailboxes = objWMIExchange.InstancesOf(&quot;Exchange_Mailbox&quot;)
 For Each objExchangeMailbox in colExchangeMailboxes
 If Left(objExchangeMailbox.StorageGroupName, 5) &lt;&gt; &quot;Recov&quot; Then
 DataList.AddNew
 DataList(&quot;Servername&quot;) = adoRecordset.Fields(&quot;name&quot;).Value
 DataList(&quot;DisplayName&quot;) = objExchangeMailbox.MailboxDisplayName
 DataList(&quot;Size&quot;) = Round(objExchangeMailbox.Size/1024,0)
 Datalist.Update
 End If
 Next
 Set colExchange_Mailboxes = Nothing
 Set objWMIExchange = Nothing
 adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

DataList.Sort = &quot;Size DESC&quot;
DataList.MoveFirst

Do Until DataList.EOF
 Wscript.Echo DataList.Fields.Item(&quot;Size&quot;) &amp; &quot; MB ; &quot; &amp; DataList.Fields.Item(&quot;DisplayName&quot;) &amp; &quot; ; &quot; &amp;_
 DataList.Fields.Item(&quot;Servername&quot;)
 DataList.MoveNext
Loop

Datalist.Close
Set DataList = 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%2Femail%2Factive-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/"></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/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/"  data-text="Active Directory and WMI: VBscript to enumerate a sorted list of all mailboxes and their size in your AD domain" data-count="horizontal" data-via="dirkadamsky"></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/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/email/active-directory-and-wmi-vbscript-to-enumerate-a-sorted-list-of-all-mailboxes-and-their-size-in-your-ad-domain/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate all contacts in your domain</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 14:01:05 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[contacts]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=903</guid>
		<description><![CDATA[This is my first post for 2011. Last week I had to do some work on Active Directory contacts. For a starter I made a script that enumerates all contacts in Active Directory. Be careful: this script does not include your local contact (they are a part of your mailbox). The script is straight ahead: [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first post for 2011.</p>
<p>Last week I had to do some work on Active Directory contacts.<br />
For a starter I made a script that enumerates all contacts in Active Directory.<br />
Be careful: this script does not include your local contact (they are a part of your mailbox).<br />
The script is straight ahead: ADO query, filter on &#8216;objectclass=contacts&#8217; and off you go.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* save the script (for example c:tempenumeratecontacts.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:temp&#8221;<br />
* give &#8220;cscript enumeratecontacts.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratecontacts.vbs
' Description : script to enumerate all contacts in your domain
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 14-01-2011
' Level: beginner

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;)
strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;
strFilter = &quot;(objectClass=contact)&quot;
strAttributes = &quot;displayname, mail&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 adoRecordset = adoCommand.Execute

Do Until adoRecordset.EOF
 Wscript.echo adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;mail&quot;).Value
 adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoConnection = Nothing
Set adoCommand = Nothing
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</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%2Fcontacts%2Factive-directory-vbscript-to-enumerate-all-contacts-in-your-domain%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/"></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/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/"  data-text="Active Directory: VBscript to enumerate all contacts in your domain" data-count="horizontal" data-via="dirkadamsky"></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/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/contacts/active-directory-vbscript-to-enumerate-all-contacts-in-your-domain/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v3</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 15:26:35 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[messagerestrictions]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=868</guid>
		<description><![CDATA[Pol asked me if it is possible to enter the Distinguished Name in the textbox. So I did a small rewrite of the script (Essentially it got shorter because the GetDN function was superfluous). Follow the next steps to run the script (no admin rights needed): * find the distinguished name of the nested group [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://deludi.nl/blog/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/comment-page-1/#comment-202">Pol</a> asked me if it is possible to enter the Distinguished Name in the textbox.<br />
So I did a small rewrite of the script (Essentially it got shorter because the GetDN function was superfluous).</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* find the distinguished name of the nested group (adsiedit.msc)<br />
* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the distinguished name<br />
* save the script (for example c:\temp\enumeratesendtorights.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript enumeratesendtorights.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratesendtorights.vbs
' Description : script to enumerate the message restrictions (send to rights) of a distributionlist
' Author : dirk adamsky - deludi bv
' Version : 3.00 added Distinguished Name input option based on input from Pol (see comments on previous script), removed the smtp input option
' Date : 16-11-2010
' Level: advanced

strObject = InputBox(&quot;Please enter the Distinguished Name&quot;)
Set objSource = GetObject(&quot;LDAP://&quot; &amp; strObject)
If TypeName(objSource.authOrig) = &quot;String&quot; Then
	GetSendToRights (&quot;LDAP://&quot; &amp; objSource.authOrig)
Else
	For Each User In objSource.authOrig
		GetSendToRights (&quot;LDAP://&quot; &amp; User)
	Next
End If
If TypeName(objSource.dLMemSubmitPerms) = &quot;String&quot; Then
	EnumNestedgroup objSource.dLMemSubmitPerms
Else
	For Each Group in objSource.dLMemSubmitPerms
		EnumNestedgroup Group
	Next
End If
Set objSource = Nothing

Function GetSendToRights(strUserDN)
	On Error Resume Next
	Set objAccount = GetObject(strUserDN)
	Wscript.Echo objAccount.Mail &amp; &quot; ; &quot; &amp; objAccount.DisplayName &amp; &quot; ; direct send to rights&quot;
	Set objSecurityDescriptor = objAccount.Get(&quot;ntSecurityDescriptor&quot;)
	Set objDacl = objSecurityDescriptor.DiscretionaryAcl
	Set objAce = CreateObject(&quot;AccessControlEntry&quot;)
	For Each objAce In objDacl
		If objAce.ObjectType = &quot;{AB721A54-1E2F-11D0-9819-00AA0040529B}&quot; Then
			If (Left(objAce.Trustee,3) &lt;&gt; &quot;S-1&quot; And objAce.Trustee &lt;&gt; &quot;NT AUTHORITYSELF&quot;) Then
				GetUserDetails Mid(objAce.Trustee,9)
			End If
		End If
	Next
End Function

Function GetUserDetails(strPreW2K)
	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

	' Search entire Active Directory domain.
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName=&quot; &amp;  strPreW2K &amp; &quot;))&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;mail, displayname&quot;

	' Construct the LDAP syntax query.
	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

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	Wscript.Echo adoRecordset.Fields(&quot;mail&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; indirect send to rights&quot;
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(&quot;LDAP://&quot; &amp; strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			GetSendToRights objMember.AdsPath
		End If
	Next
	Set objGroup = Nothing
End Sub
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</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%2Fmessagerestrictions%2Factive-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"  data-text="Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v3" data-count="horizontal" data-via="dirkadamsky"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup-v3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v2</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 12:08:01 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[messagerestrictions]]></category>
		<category><![CDATA[active directory]]></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[groups]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[memberships]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=684</guid>
		<description><![CDATA[Suffering from a lack of inspiration I decided to rework a previous script. I had a request on my previous messagerestriction script. Added to the script is the option to enter the smtp address of the user or group object for which the messagerestrictions are set. I have done that by re-using code from this [...]]]></description>
			<content:encoded><![CDATA[<p>Suffering from a lack of inspiration I decided to rework a previous script.<br />
I had a request on my previous <a href="http://deludi.nl/blog/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-distributionlist/comment-page-1/#comment-104">messagerestriction script</a>.<br />
Added to the script is the option to enter the smtp address of<br />
the user or group object for which the messagerestrictions are set.<br />
I have done that by re-using code from <a href="http://deludi.nl/blog/vbscript/active-directory/active-directory-vbscript-to-change-the-groups-from-a-user-based-on-an-example-user/">this script</a>.<br />
Another question was the option to output to a file,<br />
this can be done easily by running the script like this:</p>
<p>cscript enumeratesendtorights.vbs > thefilenameofyourchoice.txt.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<p>* find the distinguished name of the nested group (adsiedit.msc)<br />
* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the distinguished name<br />
* save the script (for example c:tempenumeratesendtorights.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:temp&#8221;<br />
* give &#8220;cscript enumeratesendtorights.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratesendtorights.vbs
' Description : script to enumerate the message restrictions (send to rights) of a distributionlist
' Author : dirk adamsky - deludi bv
' Version : 2.00 added smtp input option based on input from M (see comments on previous script)
' Date : 20-08-2010 (v.1.00 date 08-02-2010)
' Level: advanced

strObject = InputBox(&quot;Please enter the smtp address&quot;)
Set objSource = GetObject(&quot;LDAP://&quot; &amp; GetDN(strObject))
If TypeName(objSource.authOrig) = &quot;String&quot; Then
	GetSendToRights (&quot;LDAP://&quot; &amp; objSource.authOrig)
Else
	For Each User In objSource.authOrig
		GetSendToRights (&quot;LDAP://&quot; &amp; User)
	Next
End If
If TypeName(objSource.dLMemSubmitPerms) = &quot;String&quot; Then
	EnumNestedgroup objSource.dLMemSubmitPerms
Else
	For Each Group in objSource.dLMemSubmitPerms
		EnumNestedgroup Group
	Next
End If
Set objSource = Nothing

Function GetDN(strMail)
	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;

	' Filter on user objects.
	strFilter = &quot;(mail=&quot; &amp;  strMail &amp; &quot;)&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;distinguishedName&quot;

	' Construct the LDAP syntax query.
	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 adoRecordset = adoCommand.Execute
	wscript.echo adoRecordset.Fields(&quot;distinguishedName&quot;).Value
	GetDN = adoRecordset.Fields(&quot;distinguishedName&quot;).Value
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing

End Function

Function GetSendToRights(strUserDN)
	On Error Resume Next
	Set objAccount = GetObject(strUserDN)
	Wscript.Echo objAccount.Mail &amp; &quot; ; &quot; &amp; objAccount.DisplayName &amp; &quot; ; direct send to rights&quot;
	Set objSecurityDescriptor = objAccount.Get(&quot;ntSecurityDescriptor&quot;)
	Set objDacl = objSecurityDescriptor.DiscretionaryAcl
	Set objAce = CreateObject(&quot;AccessControlEntry&quot;)
	For Each objAce In objDacl
		If objAce.ObjectType = &quot;{AB721A54-1E2F-11D0-9819-00AA0040529B}&quot; Then
			If (Left(objAce.Trustee,3) &lt;&gt; &quot;S-1&quot; And objAce.Trustee &lt;&gt; &quot;NT AUTHORITYSELF&quot;) Then
				GetUserDetails Mid(objAce.Trustee,9)
			End If
		End If
	Next
End Function

Function GetUserDetails(strPreW2K)
	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

	' Search entire Active Directory domain.
	Set objRootDSE = GetObject(&quot;LDAP://RootDSE&quot;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;

	' Filter on user objects.
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(sAMAccountName=&quot; &amp;  strPreW2K &amp; &quot;))&quot;

	' Comma delimited list of attribute values to retrieve.
	strAttributes = &quot;mail, displayname&quot;

	' Construct the LDAP syntax query.
	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

	' Run the query.
	Set adoRecordset = adoCommand.Execute
	Wscript.Echo adoRecordset.Fields(&quot;mail&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;displayname&quot;).Value &amp; &quot; ; indirect send to rights&quot;
	' Clean up.
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function	

Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(&quot;LDAP://&quot; &amp; strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			Call EnumNestedgroup(objMember.AdsPath)
		Else
			GetSendToRights objMember.AdsPath
		End If
	Next
	Set objGroup = Nothing
End Sub
</pre>
<p>When you have problems/questions with the script please post a reply.</p>
<p>Happy scripting.</p>
<p>Best regards,</p>
<p>Dirk Adamsky</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%2Fmessagerestrictions%2Factive-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"  data-text="Active Directory: VBscript to enumerate the message restrictions (send to rights) of a user or distributiongroup v2" data-count="horizontal" data-via="dirkadamsky"></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/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/messagerestrictions/active-directory-vbscript-to-enumerate-the-message-restrictions-send-to-rights-of-a-user-or-distributiongroup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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"></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 and WMI: VBscript to show the size of a specific mailbox</title>
		<link>http://vbscriptblog.com/vbscript/active-directory-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:07:06 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[active directory]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mailbox]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=590</guid>
		<description><![CDATA[Today I made a script as requested by Jamal. It is a further development of a script to enumerate all exchange mailboxes and their size which can be found here. What the script does: ask for the smtp address of the mailbox get the displayname and homembd properties of that mailbox enumerate all exchange servers [...]]]></description>
			<content:encoded><![CDATA[<p>Today I made a script as requested by Jamal.<br />
It is a further development of a script to enumerate all exchange mailboxes and their size which can be found <a href="http://deludi.nl/blog/vbscript/active-directory/exchange-active-directory-vbscript/active-directory-and-wmi-vbscript-to-enumerate-all-mailboxes-and-their-size-of-your-ad-domain/#comments">here</a>.</p>
<p>What the script does:</p>
<ul>
<li>ask for the smtp address of the mailbox</li>
<li>get the displayname and homembd properties of that mailbox</li>
<li>enumerate all exchange servers</li>
<li>make a wmi connection with the exchange server on which the mailbox resides</li>
<li>get the size of the mailbox</li>
</ul>
<p>The script is tested in an win2003/exchange2003 environment.</p>
<p>Follow the next steps to run the script  (admin rights needed):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:tempmailboxsize.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript mailboxsize.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : mailboxsize.vbs
' Description : script to show the size of a specific mailbox
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 18-05-2010
' Level: advanced

Dim strDisplayName, strHomeMDB
strSMTP = InputBox(&quot;Please fill in the SMTP address of the user&quot;)
GetDisplayNameAndHomeMDB(strSMTP)

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;configurationnamingcontext&quot;) &amp; &quot;&gt;&quot;
strFilter = &quot;(objectCategory=msExchExchangeServer)&quot;
strAttributes = &quot;name&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 adoRecordset = adoCommand.Execute

Do Until adoRecordset.EOF
	If Instr(strHomeMDB,adoRecordset.Fields(&quot;name&quot;).Value) &gt; 1 Then
		Set objWMIExchange = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!//&quot;&amp;_
		adoRecordset.Fields(&quot;name&quot;).Value &amp; &quot;/root/MicrosoftExchangeV2&quot;)
		Set colExchangeMailboxes = objWMIExchange.ExecQuery(&quot;Select * From Exchange_Mailbox Where MailboxDisplayName = '&quot; &amp; strDisplayName &amp; &quot;'&quot;)
		For Each objExchangeMailbox in colExchangeMailboxes
			If Left(objExchangeMailbox.StorageGroupName, 5) &lt;&gt; &quot;Recov&quot; Then
				Wscript.Echo adoRecordset.Fields(&quot;name&quot;).Value &amp; &quot; ; &quot; &amp; objExchangeMailbox.MailboxDisplayName &amp; &quot; ; &quot; &amp;_
				Round(objExchangeMailbox.Size/1024,0) &amp; &quot; MB&quot;
			End If
		Next
		Set colExchange_Mailboxes = Nothing
		Set objWMIExchange = Nothing
	End If
	adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoRecordset = Nothing
Set objRootDSE = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function GetDisplayNameAndHomeMDB(strMail)
	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;)
	strDNSDomain = objRootDSE.Get(&quot;defaultNamingContext&quot;)
	strBase = &quot;&lt;LDAP://&quot; &amp; strDNSDomain &amp; &quot;&gt;&quot;
	strFilter = &quot;(&amp;(objectCategory=person)(objectClass=user)(mail=&quot; &amp;  strMail &amp; &quot;))&quot;
	strAttributes = &quot;displayName,homeMDB&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 adoRecordset = adoCommand.Execute
	strDisplayName = adoRecordset.Fields(&quot;displayName&quot;).Value
	strHomeMDB = adoRecordset.Fields(&quot;homeMDB&quot;).Value
	adoRecordset.Close
	adoConnection.Close

	Set adoRecordset = Nothing
	Set objRootDSE = Nothing
	Set adoConnection = Nothing
	Set adoCommand = Nothing
End Function
</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>
<p>[adrotate group="2"] </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-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox%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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/"></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-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/"  data-text="Active Directory and WMI: VBscript to show the size of a specific mailbox" data-count="horizontal" data-via="dirkadamsky"></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-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory-and-wmi-vbscript-to-show-the-size-of-a-specific-mailbox/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Active Directory: Vbscript to enumerate the lastlogon of all users of a nested group</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-group/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-group/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 12:14:01 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[citrix]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[nested group]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[smtp address]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=558</guid>
		<description><![CDATA[Ok let&#8217;s do another nested group script. This script enumerates the lastlogon of all members of a nested group. Attention: the lastlogontimestamp attribute has a treshold of 2 weeks, so recently added users might not occur in the output of the script. Follow the next steps to run the script (no admin rights needed): copy [...]]]></description>
			<content:encoded><![CDATA[<p>Ok let&#8217;s do another nested group script.<br />
This script enumerates the lastlogon of all members of a nested group.<br />
Attention: the lastlogontimestamp attribute has a treshold of 2 weeks, so recently added users might not occur in the output of the script.</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>change the distinguished name of the nested group to your group distinguished name</li>
<li>save the script (for example c:tempenumeratenestedgrouplastlogon.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript enumeratenestedgrouplastlogon.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratenestedgrouplastlogon.vbs
' Description : script to enumerate the lastlogon of all users of a nested group
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 13-04-2010
' Level: intermediate

intBias = TimeZoneBias
strTargetGroupDN = &quot;LDAP://CN=testgroup,OU=Groups,DC=test,DC=org&quot;
EnumNestedgroup strTargetGroupDN
Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			EnumNestedgroup objMember.AdsPath
		ElseIf TypeName(objMember.lastLogonTimeStamp) &lt;&gt; &quot;Empty&quot; Then
			Set objDate = objMember.lastLogonTimeStamp
			If (Err.Number &lt;&gt; 0) Then
				dtmDate = #1/1/1601#
			Else
				dtmDate = ((((objDate.Highpart * (2^32)) + objDate.LowPart)/(600000000 - intBias))/1440) + #1/1/1601#
			End If
			Set objDate = Nothing
			Wscript.Echo objMember.DisplayName &amp; &quot; ; &quot; &amp; objMember.Mail &amp; &quot; ; &quot; &amp; dtmDate
		End If
	Next
	Set objGroup = Nothing
End Sub

Function TimeZoneBias
	strComputer = &quot;.&quot;
	Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\&quot; &amp; strComputer &amp; &quot;rootcimv2&quot;)
	Set colTimeZone = objWMIService.ExecQuery(&quot;Select * from Win32_TimeZone&quot;)
	For Each objTimeZone in colTimeZone
		TimeZoneBias = objTimeZone.Bias
	Next
	Set colTimeZone = Nothing
	Set objWMIService = Nothing
End Function
</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%2Fcitrix%2Factive-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-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/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-group/"  data-text="Active Directory: Vbscript to enumerate the lastlogon of all users of a nested group" data-count="horizontal" data-via="dirkadamsky"></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/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-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/citrix/active-directory-vbscript-to-enumerate-the-lastlogon-of-all-users-of-a-nested-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Directory: Vbscript to enumerate all users of a nested group with a citrix token</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-group/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-group/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 10:52:03 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[citrix]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[list]]></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[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=547</guid>
		<description><![CDATA[Script for today is a mutation of my previous enumerate nested group script. The script enumerates all nested group users with a citrix token. Follow the next steps to run the script (no admin rights needed): copy and paste the script in your favorite text editor change the distinguished name of the nested group to [...]]]></description>
			<content:encoded><![CDATA[<p>Script for today is a mutation of my previous <a href="http://deludi.nl/blog/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-the-members-of-nested-groups-v2/">enumerate nested group script</a>.<br />
The script enumerates all nested group users with a citrix token.</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>change the distinguished name of the nested group to your group distinguished name</li>
<li>save the script (for example c:tempenumeratenestedgrouptokens.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript enumeratenestedgrouptokens.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratenestedgrouptokens.vbs
' Description : script to enumerate the citrix tokens of a nested group
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 13-04-2010
' Level: intermediate
strTargetGroupDN = &quot;LDAP://CN=testgroup,OU=groups,DC=test,DC=org&quot;
EnumNestedgroup strTargetGroupDN
Sub EnumNestedgroup(strGroupDN)
	Set objGroup = GetObject(strGroupDN)
	For Each objMember in objGroup.Members
		If (LCase(objMember.Class) = &quot;group&quot;) Then
			EnumNestedgroup objMember.AdsPath
		ElseIf objMember.[securecomputingCom2000-SafeWord-UserID] &lt;&gt; &quot;&quot; Then
			Wscript.Echo objMember.DisplayName &amp; &quot; ; &quot; &amp; objMember.Mail &amp; &quot; ; &quot; &amp; objMember.[securecomputingCom2000-SafeWord-UserID]
		End If
	Next
	Set objGroup = Nothing
End Sub
</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%2Fcitrix%2Factive-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-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" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></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/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-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/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-group/"  data-text="Active Directory: Vbscript to enumerate all users of a nested group with a citrix token" data-count="horizontal" data-via="dirkadamsky"></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/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-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/citrix/active-directory-vbscript-to-enumerate-the-citrix-tokens-of-a-nested-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

