<?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; list</title>
	<atom:link href="http://vbscriptblog.com/tag/list/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 nested Active Directory groups from an Excel sheet</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 13:09:34 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[groups]]></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[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://vbscriptblog.com/?p=1277</guid>
		<description><![CDATA[Haven&#8217;t done much scripting lately&#8230;.. The script for today is made for Ananth Kumar. He asked me to make an extension to the &#8220;enumerate nested groups script&#8221; so that multiple nested groups can be enumerated based on an input file. I did choose Excel for the input file so that i could reuse previous code. [...]]]></description>
			<content:encoded><![CDATA[<p>Haven&#8217;t done much scripting lately&#8230;..<br />
The script for today is made for Ananth Kumar.<br />
He asked me to make an extension to the <a href="http://vbscriptblog.com/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-the-members-of-nested-groups-v2/" title=""enumerate nested groups script"">&#8220;enumerate nested groups script&#8221;</a> so that multiple nested groups can be enumerated based on an input file.<br />
I did choose Excel for the input file so that i could reuse previous code.</p>
<p>Follow the next steps to run the script (no admin rights needed):</p>
<ul>
<li>find the distinguished names of the nested groups (adsiedit.msc)</li>
<li>put them in an Excel sheet in the first column ans save the sheet as c:\temp\groups.xls</li>
<li>open your favorite text editor</li>
<li>copy and paste the script below into the editor (you can use the icons in the upper rights corner of the code)</li>
<li>save the script (for example c:\temp\enumeratenestedgroupsfromexcelsheet.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:\temp&#8221;</li>
<li>give &#8220;cscript enumeratenestedgroupsfromexcelsheet.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumeratenestedgroupsfromexcelsheet.vbs
' Description : script to enumerate nested Active Directory groups from an Excel sheet
' Author : dirk adamsky - deludi bv
' Version : 1.0
' Date : 04-10-2011

Set objExcel = CreateObject(&quot;Excel.Application&quot;)
Set objWorkbook = objExcel.Workbooks.Open(&quot;C:\temp\groups.xls&quot;)
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = &quot;&quot;
strGroupDN = objExcel.Cells(intRow, 1).Value
If strGroupDN &lt;&gt; &quot;&quot; Then
wscript.echo strGroupDN
EnumNestedgroup &quot;LDAP://&quot; &amp; strGroupDN
End If
intRow = intRow + 1
Loop
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing

Function EnumNestedgroup(strGroupDN)
Set objGroup = GetObject(strGroupDN)
For Each objMember in objGroup.Members
If (LCase(objMember.Class) = &quot;group&quot;) Then
EnumNestedgroup objMember.AdsPath
Else
Wscript.Echo objGroup.cn &amp; &quot; ; &quot; &amp; objMember.DisplayName &amp; &quot; ; &quot; &amp; objMember.Mail
End If
Next
Set objGroup = Nothing
End Function
</pre>
<p>When you have a modified version or problems/questions that you want to share please post it at the comments below.</p>
<p>Happy scripting.</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%2Fgroups%2Factive-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet%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/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/"></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/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/"  data-text="Active Directory: VBscript to enumerate nested Active Directory groups from an Excel sheet" 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/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/active-directory/groups/active-directory-vbscript-to-enumerate-nested-active-directory-groups-from-an-excel-sheet/feed/</wfw:commentRss>
		<slash:comments>0</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" 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/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">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/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: VBscript to enumerate the local profile size of all computers and users in Active Directory</title>
		<link>http://vbscriptblog.com/vbscript/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-users-in-active-directory/</link>
		<comments>http://vbscriptblog.com/vbscript/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-users-in-active-directory/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 13:43:49 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[localprofiles]]></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[filesystem object]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://vbscriptblog.com/?p=1220</guid>
		<description><![CDATA[This script is made for Mike. He asked for a script to enumerate all local profiles and their size of the computers in his network. Complicating factor is the use of both Windows XP and Windows 7 clients. As you probably know that they have different local profile paths: Windows XP &#8211; &#8220;c:\documents and settings&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>This script is made 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/">Mike</a>.<br />
He asked for a script to enumerate all local profiles and their size of the computers in his network.<br />
Complicating factor is the use of both Windows XP and Windows 7 clients.<br />
As you probably know that they have different local profile paths:</p>
<p>Windows XP &#8211; &#8220;c:\documents and settings&#8221;</p>
<p>Windows 7 &#8211; &#8220;c:\users&#8221;</p>
<p>The script has to do:</p>
<ul>
<li>get all Windows XP and Windows 7 clients from Active Directory</li>
<li>check if they are online</li>
<li>get the local profiles and their sizes from each machine</li>
<li>write the values to a central logfile</li>
</ul>
<p>Follow the next steps to run the script (local admin rights needed for access to the target pc&#8217;s):</p>
<p>* open your favorite text editor<br />
* copy and paste the script into the editor<br />
* change the logfile location in line 73 (now c:\temp)<br />
* save the script (for example c:\temp\localprofiles.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript localprofiles.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : localprofiles.vbs
' Description : script to enumerate the local profile size of all computers and users in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 28-06-2011

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=computer)(|(operatingSystem=Windows XP Professional)(operatingSystem=Windows 7*)))&quot;
strAttributes = &quot;name, operatingSystem&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
	strHostname = adoRecordset.Fields(&quot;name&quot;).Value
	If CheckStatus(strHostname) = True Then
		If Instr(adoRecordset.Fields(&quot;operatingSystem&quot;).Value, &quot;XP&quot;) &gt; 0 Then
			strLocalProfilePath = &quot;\Documents and Settings\&quot;
		ElseIf Instr(adoRecordset.Fields(&quot;operatingSystem&quot;).Value, &quot;7&quot;) &gt; 0 Then
			strLocalProfilePath = &quot;\users\&quot;
		End If
		GetLocalProfileSize strHostname, &quot;\\&quot; &amp; strHostname &amp; &quot;\c$&quot; &amp; strLocalProfilePath
	End If
	adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

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

Function CheckStatus(strAddress)
	Dim objPing, objRetStatus
	Set objPing = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}&quot;).ExecQuery _
      (&quot;select * from Win32_PingStatus where address = '&quot; &amp; strAddress &amp; &quot;'&quot;)
	For Each objRetStatus In objPing
        If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode &lt;&gt; 0 Then
			CheckStatus = False
        Else
			CheckStatus = True
        End If
    Next
	Set objPing = Nothing
End Function

Function GetLocalProfileSize(strTargetMachine, strFolder)
	Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	Set objFolder = objFSO.GetFolder(strFolder)
	For Each SubFolder in objFolder.SubFolders
		Logprint strTargetMachine &amp; &quot; ; &quot; &amp; SubFolder.Name &amp; &quot; ; &quot; &amp; SubFolder.Path &amp; &quot; ; &quot; &amp; Round(SubFolder.Size/1048576,2) &amp; &quot; MB&quot;
	Next
	Set objFolder = Nothing
	Set objFSO = Nothing
End Function

Function LogPrint(Message)
Const ForAppending = 8
strDate = Replace(Date,&quot;/&quot;,&quot;-&quot;)
Set ObjFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objTextFile = ObjFSO.OpenTextFile(&quot;c:\temp\&quot; &amp; strDate &amp; &quot;-localprofiles.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. 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%2Flocalprofiles%2Factive-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-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" 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/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-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/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-users-in-active-directory/"  data-text="Active Directory: VBscript to enumerate the local profile size of all computers and users in Active Directory" 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/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-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/localprofiles/active-directory-vbscript-to-enumerate-the-local-profile-size-of-all-computers-and-users-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>10</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" 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/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">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/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>2</slash:comments>
		</item>
		<item>
		<title>VBscript: Vbscript to enumerate all accounts with Password Never Expires enabled in Active Directory</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-in-active-directory/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-in-active-directory/#comments</comments>
		<pubDate>Wed, 11 May 2011 10:59:31 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[accounts]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=1032</guid>
		<description><![CDATA[Had some questions on accounts with the &#8220;Password Never Expires&#8221; setting enabled. This script enumerates all user accounts in Active Directory en checks if the &#8220;Password Never Expires&#8221; marker is set. The check is no simple 1 or 0 but a bitwise comparison of the userAccountControl Value with ADS_UF_DONT_EXPIRE_PASSWD (or &#038;H10000 in vbs hex code). [...]]]></description>
			<content:encoded><![CDATA[<p>Had some questions on accounts with the &#8220;Password Never Expires&#8221; setting enabled.</p>
<p>This script enumerates all user accounts in Active Directory en checks if the &#8220;Password Never Expires&#8221;<br />
 marker is set.<br />
The check is no simple 1 or 0 but a bitwise comparison of the userAccountControl Value with<br />
 ADS_UF_DONT_EXPIRE_PASSWD (or &#038;H10000 in vbs hex code).<br />
userAccountControl Value for accounts with &#8220;Password Never Expires&#8221; not enabled -<br />
 Decimal: 512 &lt;=&gt; Binary: 1000000000.<br />
ADS_UF_DONT_EXPIRE_PASSWD &#8211; Hexadecimal (vbs):  &amp;H10000 &lt;=&gt;<br />
 Decimal: 65536 &lt;=&gt; Binary: 10000000000000000.</p>
<p>In the example above the binary comparison gives a zero as result, all non-zero results implicate that the value is enabled.</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:\temp\PasswordNeverExpires.vbs)<br />
* open a command prompt<br />
* go to &#8220;c:\temp&#8221;<br />
* give &#8220;cscript PasswordNeverExpires.vbs&#8221; (without quotes) and enter</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : PasswordNeverExpires.vbs
' Description : script to enumerate all accounts with Password Never Expires enabled in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 11-05-2011
' Level: Intermediate

Const ADS_UF_DONT_EXPIRE_PASSWD = &amp;H10000
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))&quot;
strAttributes = &quot;cn,mail,distinguishedName&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
	Set objUser = GetObject(&quot;LDAP://&quot; &amp; adoRecordset.Fields(&quot;distinguishedName&quot;).Value)
	If (objUser.userAccountControl And ADS_UF_DONT_EXPIRE_PASSWD) &lt;&gt; 0 Then
		Wscript.echo adoRecordset.Fields(&quot;cn&quot;).Value &amp; &quot; ; &quot; &amp; adoRecordset.Fields(&quot;mail&quot;).Value
	End If
	Set objUser = Nothing
    adoRecordset.MoveNext
Loop

adoRecordset.Close
adoConnection.Close

Set adoRecordset = Nothing
Set objRootDSE = Nothing
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%2Faccounts%2Fvbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-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" 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/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-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/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-in-active-directory/"  data-text="VBscript: Vbscript to enumerate all accounts with Password Never Expires enabled in Active Directory" 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/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-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/accounts/vbscript-vbscript-to-enumerate-all-accounts-with-password-never-expires-enabled-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>VBscript and WMI: VBscript to find files with specific extensions and creation date on remote servers</title>
		<link>http://vbscriptblog.com/vbscript/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 14:27:40 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[files]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=993</guid>
		<description><![CDATA[I recently got the question to find all Symantec BESR snaphot files older than 2 weeks (the retention period) on the company servers. This so that we could clear up some space on the snapshot volumes. I decided to make a general purpose script of it. You can use it to find old logfiles, etc. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got the question to find all <a href="http://www.symantec.com/business/backup-exec-system-recovery-server-edition">Symantec BESR</a> snaphot files older than 2 weeks (the retention period) on the company servers. This so that we could clear up some space on the snapshot volumes.<br />
I decided to make a general purpose script of it.<br />
You can use it to find old logfiles, etc.</p>
<p>What the script does:</p>
<ul>
<li>create an array with all server you want to check (replace srv001, etc with your server names)</li>
<li>create a variable with a date of 2 weeks ago (Date -14)(can easily be changed in 30, 60 days ago)</li>
<li>change the variable date to the UTC date of 14 days ago (because WMI works with UTC dates)</li>
<li>for each server in the array</li>
<li>make a wmi connection</li>
<li>query for files with specific extensions and a creation date older than 14 days ago</li>
<li>in this example i took .txt and .csv extensions, change them in whatever filetype you want</li>
</ul>
<p>The script is tested in an win2003 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>replace the strings &#8216;srv001&#8242; and &#8216;srv002&#8242; with the name of your exchange server</li>
<li>replace the extensions &#8216;txt&#8217; and &#8216;csv with the extensions you need</li>
<li>save the script (for example c:tempfindoldfileswithspecificextensions.vbs)(or something shorter..)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript findoldfileswithspecificextensions.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>When you want the output in a file please give this command:</p>
<p>&#8220;cscript findoldfileswithspecificextensions.vbs &gt; findoldfileswithspecificextensions.txt&#8221; (again without the quotes)</p>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : findoldfileswithspecificextensions.vbs
' Description : VBscript to find files with specific extensions and creation date on remote servers
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 21-03-2011
' Level: intermediate

arrServers = Array(&quot;srv001&quot;,&quot;srv002&quot;)
strDate = Date - 14
Set objDateToUtcDate = CreateObject(&quot;WbemScripting.SWbemDateTime&quot;)
objDateToUtcDate.SetVarDate(strDate)

For Each Server in arrServers
	Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\&quot; &amp; Server &amp; &quot;rootcimv2&quot;)
	Set colFiles = objWMIService.ExecQuery(&quot;Select * from CIM_DataFile where (Extension = 'txt' or Extension = 'csv') and CreationDate &lt; '&quot; &amp; objDateToUtcDate &amp; &quot;'&quot;)
	For Each objFile in colFiles
		Wscript.Echo objFile.Name
	Next
	Set colFiles = Nothing
	Set objWMIService = Nothing
Next
Set objDateToUtcDate = 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%2Fwmi%2Ffiles-wmi%2Fvbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers%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/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/"></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/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/"  data-text="VBscript and WMI: VBscript to find files with specific extensions and creation date on remote servers" 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/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi/files-wmi/vbscript-and-wmi-vbscript-to-find-files-with-specific-extensions-and-creation-date-on-remote-servers/feed/</wfw:commentRss>
		<slash:comments>1</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" 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/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">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/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" 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/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">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/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 and WMI: VBscript to enumerate the ntfs rights of a given UNC path and a given level of subfolders</title>
		<link>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 11:39:09 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[ntfsrights]]></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[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[subfolders]]></category>
		<category><![CDATA[user]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=779</guid>
		<description><![CDATA[Today I have extended the previous script: it now also enumerates the NTFS rights of subfolders below the share. As a bonus the level of subfolders can be set Follow the next steps to run the script (admin rights needed for the WMI connection): copy and paste the script in your favorite text editor save [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have extended the <a href="http://deludi.nl/blog/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/">previous script:</a><br />
it now also enumerates the NTFS rights of subfolders below the share.<br />
As a bonus the level of subfolders can be set</p>
<p>Follow the next steps to run the script (admin rights needed for the <a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation" target="_blank">WMI</a> connection):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:\temp\uncacl2.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:\temp&#8221;</li>
<li>give &#8220;cscript uncacl2.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : uncacl2.vbs
' Description : script to enumerate the ntfs rights of a given UNC path and a given level of subfolders
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 22-10-2010

strUNCPathName = InputBox(&quot;please supply the UNC path to the shared folder&quot;)
strSubfolderLevel = InputBox(&quot;please supply the subfolder depth (1,2,etc.)&quot;)
arrUNC = split(strUNCPathName,&quot;\&quot;)
If Ubound(arrUNC) &gt; 3 Then
strRightPartOfPath = Mid(strUNCPathName,(Instr(strUNCPathName,arrUNC(4)) -1))
End If
Set objWMI = GetObject(&quot;winmgmts:\\&quot; &amp; arrUNC(2) &amp; &quot;\root\CIMV2&quot;)
Set objFileShare = objWMI.Get(&quot;Win32_Share.Name=&quot;&quot;&quot; &amp; arrUNC(3) &amp; &quot;&quot;&quot;&quot;)
If Right(arrUNC(3),1) = &quot;$&quot; And Len(arrUNC(3)) = 2 Then
strPath = objFileShare.Path &amp; Mid(strRightPartOfPath,2)
Else
strPath = objFileShare.Path &amp; strRightPartOfPath
End If
ShowACL strPath
ViewSubFolders strPath, strSubfolderLevel
Set objFileShare = Nothing
Set objWMI = Nothing

Function ViewSubfolders(strFolder, strMaxlevel)
Set colSubfolders = objWMI.ExecQuery(&quot;Associators Of {Win32_Directory.Name='&quot; &amp; strFolder &amp; &quot;'} &quot; &amp;_
&quot;Where AssocClass = Win32_Subdirectory ResultRole = PartComponent&quot;)
If strMaxlevel &gt;= 1 Then
    For Each SubFolder in colSubfolders
        wscript.echo SubFolder.Name
        ShowACL SubFolder.Name
        ViewSubFolders SubFolder.Name, (strMaxlevel - 1)
    Next
End If
Set colSubfolders = Nothing
End Function

Function ShowACL(strDir)
Set objFolderSecuritySettings = objWMI.Get(&quot;Win32_LogicalFileSecuritySetting.Path='&quot; &amp; strDir &amp; &quot;'&quot;)
objFolderSecuritySettings.GetSecurityDescriptor objSD
For Each objAce in objSD.DACL
    Select Case objAce.AccessMask
        Case 1179817
            strRights = &quot;read-only&quot;
        Case 2032127
            strRights = &quot;full-control&quot;
        Case 1245631
            strRights = &quot;change&quot;
    End Select
Wscript.Echo strUNCPathName &amp; &quot; ; &quot; &amp; strDir &amp; &quot; ; &quot; &amp; objAce.Trustee.Domain &amp; &quot; ; &quot; &amp; objAce.Trustee.Name &amp; &quot; ; &quot; &amp; strRights
Next
Set objSD = Nothing
Set objFolderSecuritySettings = 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%2Fwmi%2Fntfsrights%2Factive-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders%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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/"></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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/"  data-text="Active Directory and WMI: VBscript to enumerate the ntfs rights of a given UNC path and a given level of subfolders" 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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path-and-a-given-level-of-subfolders/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Active Directory and WMI: VBscript to enumerate the ntfs rights of a given UNC path</title>
		<link>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 11:29:22 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[ntfsrights]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[GetSecurityDescriptor]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[ntfs rights]]></category>
		<category><![CDATA[unc path]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[Win32_LogicalFileSecuritySetting]]></category>
		<category><![CDATA[Win32_Share.Name]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=763</guid>
		<description><![CDATA[Last weeks I haven&#8217;t done much scripting (lack of inspiration, bad weather, etc.). But today I finished a script that I wanted to make for quite some time. The script enumerates the NTFS rights (to be more precisely a subset of the possible NTFS rights: read, change and full-control) of a given UNC path. What [...]]]></description>
			<content:encoded><![CDATA[<p>Last weeks I haven&#8217;t done much scripting (<a target="_blank" href="http://www.galactic-guide.com/articles/6R34.html" class="broken_link">lack of inspiration</a>, bad weather, etc.).<br />
But today I finished a script that I wanted to make for quite some time.<br />
The script enumerates the <a target="_blank" href="http://www.windowsecurity.com/articles/Understanding-Windows-NTFS-Permissions.html">NTFS rights</a> (to be more precisely a subset of the possible NTFS rights: read, change and full-control) of a given <a target="_blank" href="http://en.wikipedia.org/wiki/Path_%28computing%29">UNC path</a>.<br />
What the script does:</p>
<ul>
<li>ask for a UNC path</li>
<li>split the UNC path and put the substrings in an array</li>
<li>make a wmi connection to the target server</li>
<li>find the absolut path of the share</li>
<li>enumerate the acl&#8217;s</li>
<li>close the used objects</li>
</ul>
<p>Follow the next steps to run the script  (admin rights needed for the <a target="_blank" href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation">WMI</a> connection):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:tempuncacl.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript uncacl.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : uncacl.vbs
' Description : script to enumerate the ntfs rights of a given UNC path
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 20-10-2010

strUNCPathName = InputBox(&quot;please supply the UNC path to the shared folder&quot;)
arrUNC = split(strUNCPathName,&quot;&quot;)
If Ubound(arrUNC) &gt; 3 Then
	strRightPartOfPath = Mid(strUNCPathName,(Instr(strUNCPathName,arrUNC(4)) -1))
End If
Set objWMI = GetObject(&quot;winmgmts:\&quot; &amp; arrUNC(2) &amp; &quot;rootCIMV2&quot;)
Set objFileShare = objWMI.Get(&quot;Win32_Share.Name=&quot;&quot;&quot; &amp; arrUNC(3) &amp; &quot;&quot;&quot;&quot;)
If Right(arrUNC(3),1) = &quot;$&quot; And Len(arrUNC(3)) = 2 Then
	strPath = objFileShare.Path &amp; Mid(strRightPartOfPath,2)
Else
	strPath = objFileShare.Path &amp; strRightPartOfPath
End If
Set objFolderSecuritySettings = objWMI.Get(&quot;Win32_LogicalFileSecuritySetting.Path='&quot; &amp; strPath &amp; &quot;'&quot;)
objFolderSecuritySettings.GetSecurityDescriptor objSD
For Each objAce in objSD.DACL
	Select Case objAce.AccessMask
		Case 1179817
			strRights = &quot;read-only&quot;
		Case 2032127
			strRights = &quot;full-control&quot;
		Case 1245631
			strRights = &quot;change&quot;
	End Select
	Wscript.Echo strUNCPathName &amp; &quot; ; &quot; &amp; strPath &amp; &quot; ; &quot; &amp; objAce.Trustee.Domain &amp; &quot; ; &quot; &amp; objAce.Trustee.Name &amp; &quot; ; &quot; &amp; strRights
Next
Set objSD = Nothing
Set objFolderSecuritySettings = Nothing
Set objFileShare = Nothing
Set objWMI = 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>
<p>[adrotate group="3"] </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%2Fwmi%2Fntfsrights%2Factive-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path%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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/"></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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/"  data-text="Active Directory and WMI: VBscript to enumerate the ntfs rights of a given UNC path" 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/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi/ntfsrights/active-directory-and-wmi-vbscript-to-enumerate-the-ntfs-rights-of-a-given-unc-path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

