<?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>Wayne Zimmerman&#039;s Blog &#187; CSV</title>
	<atom:link href="http://www.waynezim.com/tag/csv/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.waynezim.com</link>
	<description>My World of Tech, Life and Anything Else</description>
	<lastBuildDate>Thu, 11 Mar 2010 05:02:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Report Workstation Uptime in a CSV using Active Directory and VBS</title>
		<link>http://www.waynezim.com/2009/07/report-workstation-uptime-in-a-csv-using-active-directory-and-vbs/</link>
		<comments>http://www.waynezim.com/2009/07/report-workstation-uptime-in-a-csv-using-active-directory-and-vbs/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 19:56:09 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Computer]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Report]]></category>
		<category><![CDATA[Uptime]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=437</guid>
		<description><![CDATA[Have you ever been left wondering which computers on your domain have been neglected by their user and not restarted in forever? This is a question that come up in my office every once and a while. One of the easiest ways to solve this problem is to ask WMI for when the computer was [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been left wondering which computers on your domain have been neglected by their user and not restarted in forever? This is a question that come up in my office every once and a while. One of the easiest ways to solve this problem is to ask WMI for when the computer was last restarted and subtract it from the current time. Also, while asking WMI questions you might as well ask which user is currently logged on the PC that way you know who to blame. This is exactly what the following script does for your domain. It grabs the list of workstations from the domain then queries WMI for the last time the computer is restarted and does some conversion and math and makes you an nice CSV that you can play with. </p>
<p><b>Script Configuration</b><br />
Before running this script there is some minor configuration that must be done so it can communicate with your Active Directory setup.
<ol>
<li>Find <code>objConnection.Open "Active Directory Server"</code> change <em>Active Directory Server</em> to the name of your Domain Controller</li>
<li>Find <code>objCommand.CommandText = _<br />
    "Select Name, Location from 'LDAP://OU=Workstations,DC=west,DC=domain,DC=edu' " _<br />
        &#038; "Where objectClass='computer'"</code> change <em>subdomain</em>, <em>domain</em>, and <em>suffix</em> to the name of your domain i.e. west domain edu (respectively)</li>
<li>Find <code>GetUptime objRecordSet.Fields("Name").Value, "C:\uptime.csv"</code> and change <em>C:\uptime.csv</em> to the location where you want the file saved. Be sure to save it with the extension CSV
</ol>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=437&amp;download=GetUptime.vbs">GetUptime.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4372"><td class="code" id="p437code2"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Const</span> ADS_SCOPE_SUBTREE = 2
&nbsp;
<span style="color: #000080;">Set</span> objConnection = CreateObject(<span style="color: #800000;">&quot;ADODB.Connection&quot;</span>)
<span style="color: #000080;">Set</span> objCommand =   CreateObject(<span style="color: #800000;">&quot;ADODB.Command&quot;</span>)
objConnection.Provider = <span style="color: #800000;">&quot;ADsDSOObject&quot;</span>
objConnection.<span style="color: #000080;">Open</span> <span style="color: #800000;">&quot;Active Directory Server&quot;</span> 
&nbsp;
<span style="color: #000080;">Set</span> objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    <span style="color: #800000;">&quot;Select Name, Location from 'OU=Workstations,DC=west,DC=domain,DC=edu' &quot;</span> _
        &amp; <span style="color: #800000;">&quot;Where objectClass='computer'&quot;</span>  
objCommand.Properties(<span style="color: #800000;">&quot;Page Size&quot;</span>) = 1000
objCommand.Properties(<span style="color: #800000;">&quot;Searchscope&quot;</span>) = ADS_SCOPE_SUBTREE 
<span style="color: #000080;">Set</span> objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
&nbsp;
<span style="color: #000080;">Do</span> <span style="color: #000080;">Until</span> objRecordSet.EOF
	GetUptime objRecordSet.Fields(<span style="color: #800000;">&quot;Name&quot;</span>).Value, <span style="color: #800000;">&quot;C:\uptime.csv&quot;</span>
    objRecordSet.MoveNext
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #000080;">Sub</span> GetUptime(strComputer, strFilename)
	<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span>
	<span style="color: #000080;">Set</span> StdOut = WScript.StdOut
&nbsp;
	<span style="color: #000080;">Set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;scripting.filesystemobject&quot;</span>)
	<span style="color: #000080;">Set</span> logStream = objFSO.opentextfile(strFilename, 8, <span style="color: #000080;">True</span>)
&nbsp;
	<span style="color: #000080;">Set</span> oReg=GetObject(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
	<span style="color: #000080;">If</span> Err.Number <span style="color: #000080;">Then</span>
	      logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Offline&quot;</span>)
	      Err.Clear
	<span style="color: #000080;">Else</span>
		<span style="color: #000080;">Set</span> objWMIService = GetObject _
			(<span style="color: #800000;">&quot;winmgmts:\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
		<span style="color: #000080;">Set</span> colOperatingSystems = objWMIService.ExecQuery _
			(<span style="color: #800000;">&quot;Select * from Win32_OperatingSystem&quot;</span>)
		<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objOS <span style="color: #000080;">in</span> colOperatingSystems
			dtmBootup = objOS.LastBootUpTime
			dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
			dtmSystemUptime = DateDiff(<span style="color: #800000;">&quot;h&quot;</span>, dtmLastBootUpTime, Now()) 
		<span style="color: #000080;">Next</span>
		<span style="color: #000080;">Set</span> objWMIService = GetObject _
			(<span style="color: #800000;">&quot;winmgmts:\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\cimv2&quot;</span>)
		<span style="color: #000080;">Set</span> colComputerSys = objWMIService.ExecQuery _
			(<span style="color: #800000;">&quot;Select UserName from Win32_ComputerSystem&quot;</span>)
		<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objCS <span style="color: #000080;">in</span> colComputerSys
			username = objCS.UserName
			logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Online,&quot;</span> &amp; dtmSystemUptime &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; dtmLastBootupTime &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; username) 
		<span style="color: #000080;">Next</span>
&nbsp;
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
	logStream.<span style="color: #000080;">Close</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
<span style="color: #000080;">Function</span> WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = <span style="color: #000080;">CDate</span>(Mid(dtmBootup, 5, 2) &amp; <span style="color: #800000;">&quot;/&quot;</span> &amp; _
         Mid(dtmBootup, 7, 2) &amp; <span style="color: #800000;">&quot;/&quot;</span> &amp; Left(dtmBootup, 4) _
         &amp; <span style="color: #800000;">&quot; &quot;</span> &amp; Mid (dtmBootup, 9, 2) &amp; <span style="color: #800000;">&quot;:&quot;</span> &amp; _
         Mid(dtmBootup, 11, 2) &amp; <span style="color: #800000;">&quot;:&quot;</span> &amp; Mid(dtmBootup, _
         13, 2))
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/07/report-workstation-uptime-in-a-csv-using-active-directory-and-vbs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List All Active Directory User Accounts in a CSV</title>
		<link>http://www.waynezim.com/2009/05/list-all-active-directory-user-accounts-in-a-csv/</link>
		<comments>http://www.waynezim.com/2009/05/list-all-active-directory-user-accounts-in-a-csv/#comments</comments>
		<pubDate>Wed, 20 May 2009 20:51:03 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=185</guid>
		<description><![CDATA[We all know maintaining hundreds of user accounts can be frustrating especially when it comes to audit time and you need a good list of information to pass on to an auditor. Well today I am your savory, this simple script will produce you a list of users with some detailed information that can make [...]]]></description>
			<content:encoded><![CDATA[<p>We all know maintaining hundreds of user accounts can be frustrating especially when it comes to audit time and you need a good list of information to pass on to an auditor. Well today I am your savory, this simple script will produce you a list of users with some detailed information that can make audits or documentation much easier. The script creates a Comma Separated Values file or CSV that you can edit in Microsoft Excel or any standard spreadsheet application so you can customize the information before adding it to your report or audit. Below are the specific fields that this script will provide detail on for your Active Directory Users.
<p><b>User Details</b>
<ul>
<li>Name</li>
<li>Description</li>
<li>Profile Path</li>
<li>Home Drive</li>
<li>Account Disabled</li>
<li>Password Required</li>
<li>User Changable Password</li>
<li>Password Expires</li>
<li>SmartCard Required</li>
<li>Login Count</li>
<li>Last Login (date)</li>
<li>Last Password Change (date)</li>
<li>Created (date)</li>
<li>Modified (date)</li>
</ul>
<p><b>Script Configuration</b><br />
Before running this script there is some minor configuration that must be done so it can communicate with your Active Directory setup.
<ol>
<li>Find <code>objConnection.Open "Active Directory Server"</code> change <em>Active Directory Server</em> to the name of your Domain Controller</li>
<li>Find <code>objCommand.CommandText = _<br />
    "SELECT Name, description, profilePath, homeDrive, distinguishedName,userAccountControl FROM 'LDAP://dc=subdomain,dc=domain,dc=suffix' WHERE objectCategory='user'"</code> change <em>subdomain</em>, <em>domain</em>, and <em>suffix</em> to the name of your domain i.e. west consco com (respectively)</li>
<li>Find <code>Set logStream = objFSO.opentextfile("C:\domainusers.csv", 8, True)</code> and change <em>C:\domainusers.csv</em> to the location where you want the file saved. Be sure to save it with the extension CSV
</ol>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=185&amp;download=ListUserAccounts.vbs">ListUserAccounts.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1854"><td class="code" id="p185code4"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span>
<span style="color: #000080;">Const</span> ADS_SCOPE_SUBTREE = 2
&nbsp;
<span style="color: #000080;">Const</span> ADS_UF_ACCOUNTDISABLE = &amp;H0002 
<span style="color: #000080;">Const</span> ADS_UF_PASSWD_NOTREQD = &amp;H0020 
<span style="color: #000080;">Const</span> ADS_UF_PASSWD_CANT_CHANGE = &amp;H0040 
<span style="color: #000080;">Const</span> ADS_UF_DONT_EXPIRE_PASSWD = &amp;H10000 
<span style="color: #000080;">Const</span> ADS_UF_SMARTCARD_REQUIRED = &amp;H40000 
&nbsp;
<span style="color: #000080;">Set</span> objConnection = CreateObject(<span style="color: #800000;">&quot;ADODB.Connection&quot;</span>)
<span style="color: #000080;">Set</span> objCommand =   CreateObject(<span style="color: #800000;">&quot;ADODB.Command&quot;</span>)
objConnection.Provider = <span style="color: #800000;">&quot;ADsDSOObject&quot;</span>
objConnection.<span style="color: #000080;">Open</span> <span style="color: #800000;">&quot;Active Directory Server&quot;</span>
<span style="color: #000080;">Set</span> objCommand.ActiveConnection = objConnection
&nbsp;
objCommand.Properties(<span style="color: #800000;">&quot;Page Size&quot;</span>) = 1000
objCommand.Properties(<span style="color: #800000;">&quot;Searchscope&quot;</span>) = ADS_SCOPE_SUBTREE 
&nbsp;
objCommand.CommandText = _
    <span style="color: #800000;">&quot;SELECT Name, description, profilePath, homeDrive, distinguishedName,userAccountControl FROM 'LDAP://dc=subdomain,dc=domain,dc=suffix' WHERE objectCategory='user'&quot;</span>  
<span style="color: #000080;">Set</span> objRecordSet = objCommand.Execute
&nbsp;
objRecordSet.MoveFirst
<span style="color: #000080;">Set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;scripting.filesystemobject&quot;</span>)
<span style="color: #000080;">Set</span> logStream = objFSO.opentextfile(<span style="color: #800000;">&quot;C:\domainusers.csv&quot;</span>, 8, <span style="color: #000080;">True</span>)
logStream.writeline(<span style="color: #800000;">&quot;Name,Description,Profile Path,Home Drive,Account Disabled,Password Required,User Changable Password,Password Expires,SmartCard Required,Login Count,Last Login,Last Password Change,Created,Modified&quot;</span>)
<span style="color: #000080;">Do</span> <span style="color: #000080;">Until</span> objRecordSet.EOF
&nbsp;
	strDN = objRecordset.Fields(<span style="color: #800000;">&quot;distinguishedName&quot;</span>).Value 
	<span style="color: #000080;">Set</span> objUser = GetObject (<span style="color: #800000;">&quot;LDAP://&quot;</span> &amp; strDN)
&nbsp;
	<span style="color: #000080;">If</span> objRecordset.Fields(<span style="color: #800000;">&quot;userAccountControl&quot;</span>).Value <span style="color: #000080;">AND</span> ADS_UF_ACCOUNTDISABLE <span style="color: #000080;">Then</span>
		Text = <span style="color: #800000;">&quot;Yes&quot;</span>
	<span style="color: #000080;">Else</span>
		Text = <span style="color: #800000;">&quot;No&quot;</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
	<span style="color: #000080;">If</span> objRecordset.Fields(<span style="color: #800000;">&quot;userAccountControl&quot;</span>).Value <span style="color: #000080;">AND</span> ADS_UF_PASSWD_NOTREQD <span style="color: #000080;">Then</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,No&quot;</span>
	<span style="color: #000080;">Else</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,Yes&quot;</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
	<span style="color: #000080;">If</span> objRecordset.Fields(<span style="color: #800000;">&quot;userAccountControl&quot;</span>).Value <span style="color: #000080;">AND</span> ADS_PASSWORD_CANT_CHANGE <span style="color: #000080;">Then</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,No&quot;</span>
	<span style="color: #000080;">Else</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,Yes&quot;</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>	 
	<span style="color: #000080;">If</span> objRecordset.Fields(<span style="color: #800000;">&quot;userAccountControl&quot;</span>).Value <span style="color: #000080;">AND</span> ADS_UF_DONT_EXPIRE_PASSWD <span style="color: #000080;">Then</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,No&quot;</span>
	<span style="color: #000080;">Else</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,Yes&quot;</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
	<span style="color: #000080;">If</span> objRecordset.Fields(<span style="color: #800000;">&quot;userAccountControl&quot;</span>).Value <span style="color: #000080;">AND</span> ADS_UF_SMARTCARD_REQUIRED <span style="color: #000080;">Then</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,Yes&quot;</span>
	<span style="color: #000080;">Else</span>
		Text = Text &amp; <span style="color: #800000;">&quot;,No&quot;</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
	logStream.writeline(objRecordset.Fields(<span style="color: #800000;">&quot;Name&quot;</span>).Value &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objRecordset.Fields(<span style="color: #800000;">&quot;description&quot;</span>).Value &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objRecordset.Fields(<span style="color: #800000;">&quot;profilePath&quot;</span>).Value &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objRecordset.Fields(<span style="color: #800000;">&quot;homeDrive&quot;</span>).Value &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; text &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objUser.logonCount &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objUser.LastLogin &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objUser.PasswordLastChanged &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objUser.whenCreated &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		&amp; objUser.whenChanged &amp; <span style="color: #800000;">&quot;,&quot;</span>_
		)
&nbsp;
    objRecordSet.MoveNext
<span style="color: #000080;">Loop</span>
logStream.<span style="color: #000080;">Close</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/05/list-all-active-directory-user-accounts-in-a-csv/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>List Local Accounts from Computers in Active Directory</title>
		<link>http://www.waynezim.com/2009/04/list-local-accounts-from-computers-in-active-directory/</link>
		<comments>http://www.waynezim.com/2009/04/list-local-accounts-from-computers-in-active-directory/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 14:46:11 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[compmgmt.msc]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=12</guid>
		<description><![CDATA[When you finally take the plunge and decided that the only way to take your business to the next level is to setup a true client/server environment, here is a script to help you clean up those old accounts. When you convert to an Active Directory structure, you need to remove all the old local [...]]]></description>
			<content:encoded><![CDATA[<p>When you finally take the plunge and decided that the only way to take your business to the next level is to setup a true client/server environment, here is a script to help you clean up those old accounts. When you convert to an Active Directory structure, you need to remove all the old local user accounts. This will reduce the security risks by removing accounts that you can&#8217;t force to conform to the rules setup by Group Policy. Also, if you were running these users as Administrators or Power Users and now have limited them down to a Standard user, without removing their old local accounts they may have elevated rights that they don&#8217;t need. Using this script you can query every computer in you Active Directory and get a list in CSV that you can use to know where that accounts are that need to be removed. In this script you can modify the output file so you can save the file where you want. You will also need to modify the Active Directory information to match your Domain configuration.</p>
<p>Tip: You can remotely connect other computers on your domain using &#8220;compmgmt.msc /computer:[remote computer]&#8221; from there you can manage user accounts in Local Users and Groups.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.waynezim.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=12&amp;download=getlocalaccts.vbs">getlocalaccts.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p126"><td class="code" id="p12code6"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Const</span> ADS_SCOPE_SUBTREE = 2
&nbsp;
<span style="color: #000080;">Set</span> objConnection = CreateObject(<span style="color: #800000;">&quot;ADODB.Connection&quot;</span>)
<span style="color: #000080;">Set</span> objCommand =   CreateObject(<span style="color: #800000;">&quot;ADODB.Command&quot;</span>)
objConnection.Provider = <span style="color: #800000;">&quot;ADsDSOObject&quot;</span>
objConnection.<span style="color: #000080;">Open</span> <span style="color: #800000;">&quot;MYDomainController&quot;</span> <span style="color: #008000;">'put domain controller here
</span>
<span style="color: #000080;">Set</span> objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    <span style="color: #800000;">&quot;Select Name, Location from LDAP://DC=subdomain,DC=zim,DC=local' &quot;</span> _  <span style="color: #008000;">'update this with your AD information
</span>        &amp; <span style="color: #800000;">&quot;Where objectClass='computer'&quot;</span>  
objCommand.Properties(<span style="color: #800000;">&quot;Page Size&quot;</span>) = 1000
objCommand.Properties(<span style="color: #800000;">&quot;Searchscope&quot;</span>) = ADS_SCOPE_SUBTREE 
<span style="color: #000080;">Set</span> objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
&nbsp;
<span style="color: #000080;">Do</span> <span style="color: #000080;">Until</span> objRecordSet.EOF
	LocalUsers objRecordSet.Fields(<span style="color: #800000;">&quot;Name&quot;</span>).Value, <span style="color: #800000;">&quot;C:\localaccounts.csv&quot;</span> <span style="color: #008000;">'adjust output file name as needed
</span>    objRecordSet.MoveNext
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #000080;">Sub</span> LocalUsers(strComputer, strFilename)
	<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">Resume</span> <span style="color: #000080;">Next</span>
	<span style="color: #000080;">Set</span> StdOut = WScript.StdOut
&nbsp;
	<span style="color: #000080;">Set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;scripting.filesystemobject&quot;</span>)
	<span style="color: #000080;">Set</span> logStream = objFSO.opentextfile(strFilename, 8, <span style="color: #000080;">True</span>)
&nbsp;
	<span style="color: #000080;">Set</span> oReg=GetObject(<span style="color: #800000;">&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot;</span> &amp; strComputer &amp; <span style="color: #800000;">&quot;\root\default:StdRegProv&quot;</span>)
	<span style="color: #000080;">If</span> Err.Number <span style="color: #000080;">Then</span>
	      logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Offline&quot;</span>)
	      Err.Clear
	<span style="color: #000080;">Else</span>
		<span style="color: #000080;">Set</span> colAccounts = GetObject(<span style="color: #800000;">&quot;WinNT://&quot;</span> &amp; strComputer)
		colAccounts.Filter = Array(<span style="color: #800000;">&quot;user&quot;</span>)
&nbsp;
		<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objUser <span style="color: #000080;">In</span> colAccounts
		        logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Online,&quot;</span> &amp; objUser.Name &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; objUser.AccountDisabled) 
		<span style="color: #000080;">Next</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
	logStream.<span style="color: #000080;">Close</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/04/list-local-accounts-from-computers-in-active-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
