<?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; wmi</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/wmi/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 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" 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/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"></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 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" 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/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"></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">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" 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/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"></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>
		<item>
		<title>Active Directory and WMI: VBscript to enumerate the system uptime of all servers in Active Directory V2</title>
		<link>http://vbscriptblog.com/vbscript/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory-v2/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory-v2/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 06:13:40 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[active directory]]></category>
		<category><![CDATA[uptime]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>
		<category><![CDATA[alive]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=654</guid>
		<description><![CDATA[The script for today is created for Paul. It is an extension of the previous server uptime script. The uptime is now formatted in: xx days, xx hours, xx minutes. Follow the next steps to run the script (admin rights needed for the WMI connections): copy and paste the script in your favorite text editor [...]]]></description>
			<content:encoded><![CDATA[<p>The script for today is created for <a href="http://deludi.nl/blog/vbscript/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/comment-page-1/#comment-98">Paul</a>.<br />
It is an extension of the <a href="http://deludi.nl/blog/vbscript/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/">previous server uptime script</a>.<br />
The uptime is now formatted in: xx days, xx hours, xx minutes.</p>
<p><br class="spacer_" /></p>
<p>Follow the next steps to run the script  (admin rights needed for the WMI connections):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:tempserveruptimev2.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript serveruptimev2.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : serveruptimev2.vbs
' Description : script to enumerate the system uptime of all servers in Active Directory V2
' Author : dirk adamsky - deludi bv
' Version : 2.00
' Date : 15-07-2010

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=computer)(operatingSystem=*server*))&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
	On Error Resume Next
	strHostname = adoRecordset.Fields(&quot;name&quot;).Value
	If CheckStatus(strHostname) = False Then
		Wscript.Echo strHostname &amp; &quot; does not reply&quot;
	Else
		Wscript.Echo strHostname &amp; &quot; is up for &quot; &amp; GetUptime(strHostname)
	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 GetUptime(strServer)
	Set objDateTime = CreateObject(&quot;WbemScripting.SWbemDateTime&quot;)
	Set objWMIService = GetObject(&quot;winmgmts:\&quot; &amp; strServer &amp; &quot;rootcimv2&quot;)
	Set colOperatingSystems = objWMIService.ExecQuery(&quot;Select * from Win32_OperatingSystem&quot;)
	For Each objOS in colOperatingSystems
		objDateTime.Value = objOS.LastBootUpTime
		strMinutes = DateDiff(&quot;n&quot;, objDateTime.GetVarDate, Now)
		If strMinutes =&lt; 0 Then
			strUptime = &quot;0 days, 0 hours, 0 minutes&quot;
		Else
			strUptime = &quot;&quot;
			If strMinutes &gt;= 1440 Then
				strUptime = Round(strMinutes1440,0) &amp; &quot; days,&quot;
			End If
			strMinutes = strMinutes Mod 1440
			If strMinutes &gt;= 60 Then
				strUptime = strUptime &amp; (strMinutes60) &amp; &quot; hours,&quot;
			End If
			strMinutes = strMinutes Mod 60
			GetUptime = strUptime &amp; strMinutes &amp; &quot; minutes&quot;
		End If
	Next
	Set colOperatingSystems = Nothing
	Set objWMIService = Nothing
	Set objDateTime = 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" banner="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%2Factive-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory-v2/"  data-text="Active Directory and WMI: VBscript to enumerate the system uptime of all servers 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-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory-v2/feed/</wfw:commentRss>
		<slash:comments>3</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>WMI: Vbscript to enumerate who is connected to a domain controller</title>
		<link>http://vbscriptblog.com/vbscript/wmi-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 13:39:44 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[connections]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wmi]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[connected]]></category>
		<category><![CDATA[connection]]></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>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=575</guid>
		<description><![CDATA[Ok let&#8217;s do another script. The script shows you who is connected to a domain controller. This is accomplished through the WMI class &#8220;Win32_ServerSession&#8221;. Enumerated are: prew2k username, hostname, workstation os and the time connected. The script needs to be run as admin because of the wmi connection to the server. Follow the next steps [...]]]></description>
			<content:encoded><![CDATA[<p>Ok let&#8217;s do another script.<br />
The script shows you who is connected to a domain controller.<br />
This is accomplished through the WMI class &#8220;Win32_ServerSession&#8221;.<br />
Enumerated are: prew2k username, hostname, workstation os and the time connected.<br />
The script needs to be run as admin because of the wmi connection to the server.</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>change the value of strServer to the name of your domain controller (example: strServer = &#8220;srv001&#8243;)</li>
<li>save the script (for example c:tempconnected.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript connected.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : connected.vbs
' Description : script to enumerate who is connected to a domain controller
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 22-04-2010
' Level: intermediate

strServer = &quot;domaincontroller&quot;
Set objWMI = GetObject(&quot;winmgmts://&quot; &amp; strServer &amp; &quot;/rootcimv2&quot;)
Set objInstances = objWMI.InstancesOf(&quot;Win32_ServerSession&quot;,48)

For Each objInstance in objInstances
    With objInstance
        WScript.Echo .UserName &amp; &quot; ; &quot; &amp; .ComputerName &amp; &quot; ; &quot; &amp; .ClientType &amp;_
		.Name &amp; &quot; ; &quot; &amp; Round(.ActiveTime/60,0) &amp; &quot; minutes connected&quot;
    End With
Next

Set objInstances = 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>
<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-vbscript-to-enumerate-who-is-connected-to-a-domain-controller%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/wmi-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/"></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-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/"  data-text="WMI: Vbscript to enumerate who is connected to a domain controller" 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/wmi-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi-vbscript-to-enumerate-who-is-connected-to-a-domain-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Directory and WMI: VBscript to enumerate the system uptime of all servers in Active Directory</title>
		<link>http://vbscriptblog.com/vbscript/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:15:17 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[uptime]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[alive]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[server]]></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=441</guid>
		<description><![CDATA[In large Active Directory environments it is useful to know the uptime of each server (for patches, etc.). This script lists all servers in Active Directory, checks if they are alive and if so check their uptime. It can be run as a scheduled task (for example every day or week). Follow the next steps [...]]]></description>
			<content:encoded><![CDATA[<p>In large Active Directory environments it is useful to know the uptime of each server (for patches, etc.).<br />
This script lists all servers in Active Directory, checks if they are alive and if so check their uptime.<br />
It can be run as a scheduled task (for example every day or week).</p>
<p>Follow the next steps to run the script  (admin rights needed for the WMI connections):</p>
<ul>
<li>copy and paste the script in your favorite text editor</li>
<li>save the script (for example c:tempserveruptime.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript serveruptime.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : serveruptime.vbs
' Description : script to monitor all servers in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 17-03-2010

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=computer)(operatingSystem=*server*))&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
	strHostname = adoRecordset.Fields(&quot;name&quot;).Value
	If CheckStatus(strHostname) = False Then
		Wscript.Echo strHostname &amp; &quot; does not reply&quot;
	Else
		Wscript.Echo strHostname &amp; &quot; is up for &quot; &amp; GetUptime(strHostname) &amp; &quot; days&quot;
	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 GetUptime(strServer)
	Set objDateTime = CreateObject(&quot;WbemScripting.SWbemDateTime&quot;)
	Set objWMIService = GetObject(&quot;winmgmts:\&quot; &amp; strServer &amp; &quot;rootcimv2&quot;)
	Set colOperatingSystems = objWMIService.ExecQuery(&quot;Select * from Win32_OperatingSystem&quot;)
	For Each objOS in colOperatingSystems
		objDateTime.Value = objOS.LastBootUpTime
		GetUptime = DateDiff(&quot;d&quot;, objDateTime.GetVarDate, Now)
	Next
	Set colOperatingSystems = Nothing
	Set objWMIService = Nothing
	Set objDateTime = 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="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%2Fuptime%2Factive-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/"  data-text="Active Directory and WMI: VBscript to enumerate the system uptime of all servers 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/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-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/wmi/uptime/active-directory-and-wmi-vbscript-to-enumerate-the-system-uptime-of-all-servers-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Active Directory And WMI: VBscript to monitor all servers in Active Directory</title>
		<link>http://vbscriptblog.com/vbscript/active-directory/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-in-active-directory/</link>
		<comments>http://vbscriptblog.com/vbscript/active-directory/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-in-active-directory/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 13:43:05 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[monitoring]]></category>
		<category><![CDATA[ping]]></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[distribution group]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[mailbox]]></category>
		<category><![CDATA[server]]></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=384</guid>
		<description><![CDATA[The script for today is a monitoring script. Basically it is a concatenation of previous scripts/functions. The script can be run as a scheduled task (for example every half hour). What the script does: run an ado query to get all servers from Active Directory the function CheckStatus does the wmi ping to the servers [...]]]></description>
			<content:encoded><![CDATA[<p>The script for today is a monitoring script.<br />
Basically it is a concatenation of previous scripts/functions.<br />
The script can be run as a scheduled task (for example every half hour).</p>
<p>What the script does:</p>
<ul>
<li>run an ado query to get all servers from Active Directory</li>
<li>the function CheckStatus does the wmi ping to the servers and returns true or false</li>
<li>the servers that do not respond are put into a variable</li>
<li>the content of the variable is mailed to a given smtp address</li>
</ul>
<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:\tempserveralive.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:\temp&#8221;</li>
<li>give &#8220;cscript serveralive.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : serveralive.vbs
' Description : script to monitor all servers in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.10 changed ado filter
' Date : 17-03-2010

' Setup ADO objects.
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=computer)(operatingSystem=*server*))&quot;

' Comma delimited list of attribute values to retrieve.
strAttributes = &quot;name&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

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
	'On Error Resume Next
	strHostname = adoRecordset.Fields(&quot;name&quot;).Value
	If CheckStatus(strHostname) = False Then
		strNoReply = strNoReply &amp; &quot; ; &quot; &amp; strHostname
	End If
	'Move to the next record in the recordset.
    adoRecordset.MoveNext
Loop
Sendmail &quot;monitoring@monitoring.org&quot;, strNoReply &amp; &quot; are not responding!&quot; 'change the smtp address to your monitoring mailbox or distributionlist
' Clean up.
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 SendMail(strRecipient, strHeader)
	Set objMessage = CreateObject(&quot;CDO.Message&quot;)
	objMessage.Subject = strHeader
	objMessage.From = &quot;someone@test.org&quot;
	objMessage.To = strRecipient
	objMessage.TextBody = &quot;This is an automated message do not repond (or else you will be punished).&quot;
	objMessage.Configuration.Fields.Item (&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2
	objMessage.Configuration.Fields.Item (&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;smtp.test.org&quot; 'change to your smtp server
	objMessage.Configuration.Fields.Item (&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;) = 25
	objMessage.Configuration.Fields.Item (&quot;http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout&quot;) = 60
	objMessage.Configuration.Fields.Update
	objMessage.Send
	Set objMessage = 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%2Fmonitoring-active-directory-vbscript%2Factive-directory-and-wmi-vbscript-to-monitor-all-servers-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/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-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/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-in-active-directory/"  data-text="Active Directory And WMI: VBscript to monitor all servers 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/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-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/monitoring-active-directory-vbscript/active-directory-and-wmi-vbscript-to-monitor-all-servers-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WMI: VBscript to enumerate IIS virtual directories</title>
		<link>http://vbscriptblog.com/vbscript/wmi/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 12:53:23 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[iis]]></category>
		<category><![CDATA[adsi]]></category>
		<category><![CDATA[attribute]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[cscript]]></category>
		<category><![CDATA[directories]]></category>
		<category><![CDATA[HttpRedirect]]></category>
		<category><![CDATA[IIsWebVirtualDirSetting]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[virtual directory]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://deludi.nl/blog/?p=364</guid>
		<description><![CDATA[Today&#8217;s script is about Internet Information Server (IIS). It enumerates all virtual directories on an IIS server. The script is tested for server 2003 with IIS 6.0. Due to the fact that most IIS servers are in a De-Militarized Zone (DMZ) the easiest way is to run the script on the server. Follow the next [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s script is about Internet Information Server (IIS).<br />
It enumerates all virtual directories on an IIS server.<br />
The script is tested for server 2003 with IIS 6.0.<br />
Due to the fact that most IIS servers are in a De-Militarized Zone (DMZ) the easiest way is to run the script on the server.</p>
<p>Follow the next steps to make and run the script (admin rights  needed):</p>
<ul>
<li>open your favorite text editor (mine is notepad++)</li>
<li>copy and paste the script into the editor (delete the line numbers)</li>
<li>save the script (for example c:tempvdirs.vbs)</li>
<li>copy the script to the webserver</li>
<li>start an rdp session to the webserver</li>
<li>at the webserver open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript vdirs.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : vdirs.vbs
' Description : script to enumerate IIS virtual directories
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 25-02-2010
' Level : beginner

strComputer = &quot;.&quot;
Set objWMIService = GetObject(&quot;winmgmts:{authenticationLevel=pktPrivacy}\&quot; &amp; strComputer &amp; &quot;rootmicrosoftiisv2&quot;)
Set colVdirs = objWMIService.ExecQuery(&quot;Select * from IIsWebVirtualDirSetting&quot;)
For Each objVdir in colVdirs
    Wscript.Echo &quot;Name: &quot; &amp; objVdir.Name &amp; &quot; ; HttpRedirect &quot; &amp; objVdir.HttpRedirect
Next
Set colVdirs = Nothing
Set objWMIService = Nothing
</pre>
<p>As said earlier: when you have questions/problems please give a  reply.</p>
<p>You can also rate the script with the &#8220;star&#8221; rating below</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%2Fwmi%2Fiis-wmi-vbscript%2Fwmi-vbscript-to-enumerate-the-iis-virtual-directories%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/wmi/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/"></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/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/"  data-text="WMI: VBscript to enumerate IIS virtual directories" 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/wmi/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi/iis-wmi-vbscript/wmi-vbscript-to-enumerate-the-iis-virtual-directories/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WMI: VBscript to show the network shares of a computer</title>
		<link>http://vbscriptblog.com/vbscript/wmi/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/</link>
		<comments>http://vbscriptblog.com/vbscript/wmi/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:45:47 +0000</pubDate>
		<dc:creator>dirk adamsky</dc:creator>
				<category><![CDATA[shares]]></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[list]]></category>
		<category><![CDATA[network shares]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[share]]></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=280</guid>
		<description><![CDATA[Okido, here&#8217;s another starter script. This script shows all network shares on your computer. Default computer is the local machine. When the dot is replaced by another machine name the script works against that machine. With some additions the script can be used for a simple inventory of the pc&#8217;s in your network. There are [...]]]></description>
			<content:encoded><![CDATA[<p>Okido, here&#8217;s another starter script.<br />
This script shows all network shares on your computer.<br />
Default computer is the local machine.<br />
When the dot is replaced by another machine name the script works  against that machine.<br />
With some additions the script can be used for a simple inventory of the  pc&#8217;s in your network.</p>
<p>There are some conditions that must be met:</p>
<ol>
<li> the script must be run with administrative credentials</li>
<li>the firewall of the remote machine needs the following ports opened  for WMI: TCP 135, TCP 4168 and<br />
UDP 9256</li>
</ol>
<p>Follow the next steps to make and run the script (admin rights  needed):</p>
<ul>
<li>open your favorite text editor (mine is notepad++)</li>
<li>copy and paste the script into the editor (delete the line numbers)</li>
<li>save the script (for example c:tempenumerateshares.vbs)</li>
<li>open a command prompt</li>
<li>go to &#8220;c:temp&#8221;</li>
<li>give &#8220;cscript enumerateshares.vbs&#8221; (without quotes) and enter</li>
</ul>
<p>The script:</p>
<pre class="brush: vb; title: ; notranslate">
' Name : enumerateshares.vbs
' Description : script to show the model of a computer
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 09-02-2010
' Level : beginner

strComputer = &quot;.&quot;
Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\&quot; &amp; strComputer &amp; &quot;rootcimv2&quot;)
Set colShares = objWMIService.ExecQuery(&quot;Select * from Win32_Share&quot;)
Wscript.Echo &quot;name ; path ; caption&quot;
For each objShare in colShares
    Wscript.Echo objShare.Name &amp; &quot; ; &quot; &amp; objShare.Path &amp; &quot; ; &quot; &amp; objShare.Caption
Next
Set colShares = Nothing
Set objWMIService = Nothing
</pre>
<p>As said earlier: when you have questions/problems please give a  reply.</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%2Fshares%2Fwmi-vbscript-to-show-the-network-shares-of-a-computer%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/wmi/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/"></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/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/"  data-text="WMI: VBscript to show the network shares of a computer" 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/wmi/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://vbscriptblog.com/vbscript/wmi/shares/wmi-vbscript-to-show-the-network-shares-of-a-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

