<?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; connections</title>
	<atom:link href="http://vbscriptblog.com/category/vbscript/wmi/connections/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>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>
	</channel>
</rss>

