<?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; store</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/active-directory/store/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 log the mailbox store of all users</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 13:10:18 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[store]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></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=462</guid>
		<description><![CDATA[Sometimes a user account is accidentally deleted. The corresponding exchange mailbox object is still there for a month. After creating a new user object, this user object has to be connected to the old mailbox object. In a large organization the number of exchange stores/databases is often high too. This gives you as sysadmin a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes a user account is accidentally deleted. The corresponding exchange mailbox object is still there for a month.<br />
After creating a new user object, this user object has to be connected to the old mailbox object.<br />
In a large organization the number of exchange stores/databases is often high too. This gives you as sysadmin a lot of mouseclicks&#8230;. The next script helps you to get around this problem: it enumerates user and the store of the user&#8217;s mailbox and creates a logfile with datestamp. When you schedule this script let&#8217;s say weekly you can simple open the textfile of the week before the user account was deleted to find out in which store the old mailbox resides.</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:tempstore.vbs)</li>
<li> open a command prompt</li>
<li> go to &#8220;c:temp&#8221;</li>
<li> give &#8220;cscript store.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : store.vbs
' Description : script to log the mailbox store of all users
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 26-03-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=person)(objectClass=user)(mail=*))&quot;
strAttributes = &quot;cn,mail,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

Do Until adoRecordset.EOF
	LogPrint adoRecordset.Fields(&quot;cn&quot;).Value  &amp; &quot;:&quot; &amp; adoRecordset.Fields(&quot;mail&quot;).Value  &amp;_
	&quot;:&quot; &amp; adoRecordset.Fields(&quot;homemdb&quot;).Value
	adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

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

Function LogPrint(Message)
	Const ForAppending = 8
	strDate = Replace(Date,&quot;/&quot;,&quot;-&quot;)
	Set ObjFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	Set objTextFile = ObjFSO.OpenTextFile(strDate &amp; &quot;-UsersInStore.csv&quot;, ForAppending, True)
	objTextFile.WriteLine Message
	objTextFile.Close
	Set objTextFile = Nothing
	Set ObjFSO = Nothing
End Function
</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</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%2Fstore%2Factive-directory-vbscript-to-log-the-mailbox-store-of-all-users%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/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/"></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/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/"  data-text="Active Directory: VBscript to log the mailbox store of all users" 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/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/store/active-directory-vbscript-to-log-the-mailbox-store-of-all-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

