<?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; User Accounts</title>
	<atom:link href="http://www.waynezim.com/tag/user-accounts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.waynezim.com</link>
	<description>My World of Tech, Life and Anything Else</description>
	<lastBuildDate>Fri, 10 Feb 2012 00:13:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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="p1852"><td class="code" id="p185code2"><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>8</slash:comments>
		</item>
		<item>
		<title>How to Deploy VNC using Group Policy</title>
		<link>http://www.waynezim.com/2009/05/how-to-deploy-vnc-using-group-policy/</link>
		<comments>http://www.waynezim.com/2009/05/how-to-deploy-vnc-using-group-policy/#comments</comments>
		<pubDate>Wed, 13 May 2009 21:36:32 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[GPMC]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Group Policy Managment Console]]></category>
		<category><![CDATA[MSI]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[UltraVNC]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[VNC]]></category>
		<category><![CDATA[VNCed]]></category>
		<category><![CDATA[Windows Firewall]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=79</guid>
		<description><![CDATA[Do you spend too much time running from desk to desk just to help someone make a shortcut or change the default printer? This could be the solution for you. Using UltraVNC you can remotely view and control their workstation from your desk. This can save you time from running around everywhere, and make your [...]]]></description>
			<content:encoded><![CDATA[<p>Do you spend too much time running from desk to desk just to help someone make a shortcut or change the default printer? This could be the solution for you. Using UltraVNC you can remotely view and control their workstation from your desk. This can save you time from running around everywhere, and make your users happier faster by solving their problems on the spot. You can also make your boss happy be making it authenticate with Active Directory. That will ensure that everyone that has the remote support access uses their own username and password, and it is easily managed with Active Directory Groups. VNC works very simply by installing a server on every workstation which allows it to share out the desktop to other clients / viewer programs. By installing the VNC Server on all your workstations it will allow you to connect using the client / viewer application and provide hands on support directly from your workstation. </p>
<p><strong>Requirements</strong>
<ul>
<li>Microsoft Domain</li>
<li><a href="http://www.uvnc.com/download/">UltraVNC 1.0.2</a></li>
<li><a href="http://vnced.sourceforge.net/downloads.php">VNCed UltraVNC MSI Creator 1.1.3</a></li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=0A6D4C24-8CBD-4B35-9272-DD3CBFC81887&#038;displaylang=en">Group Policy Management Console</a></li>
</ul>
<p><strong>Making the MSI using VNCed</strong><br />
Now that you have the required software, the first thing we need to do is uncompress the VNCed UltraVNC MSI Creator to a folder on your desktop. Once completed, run the <b>run.bat</b> and it should popup a GUI interface you can use to configure different parts of the UltraVNC Server.<img src="http://www.waynezim.com/wp-content/uploads/2009/05/vnced-msi-creator-180x300.png" alt="VNCed UltraVNC MSI Maker" title="VNCed UltraVNC MSI Maker" width="180" height="300" class="alignright size-medium wp-image-83" /><br />Using this interface you can adjust and explore what options you have to choose from to customize your UltraVNC Deployment for your environment. The defaults here are a pretty good start and you can click on each item to get a description of what it will change. You may want to install this to a test computer a few times before rolling it out.<br />At this time you also need to configure if you will be using if you will be using Active Directory Authentication or just a plain password.
<p>
 &#8211; To setup the plain password just fill out the <em>password</em> item and leave the <em>newMSLogon</em> unchecked.<br /> &#8211; To setup Active Directory Authentication check the  <em>newMSLogon</em> and you will need to make a file to select for <em>aclImportFile</em>. This file can either be generated based on the <a href="http://www.uvnc.com/features/authentication.html#mslogonacl">UltraVNC Instructions</a> or you can use my file by creating a text file called: MSACL.ini and pasting <code>allow	0x00000003	"..\Domain Admins</code> in to it. That will allow anyone in the Domain Admins group to have full access to any machine setup using this MSI.
<p>Once you have finished configuring the options for UltraVNC hit the <em>Generate UltraVNC MSI</em> button at the bottom. This will generate your UltraVNC.msi in the folder in which VNCed was extracted to. This file is what you will use to deploy UltraVNC to your workstations. </p>
<p><strong>Using Group Policy to Deploy the MSI</strong><br />
First you will need to open either your <em>Group Policy Management Console (gpmc.msc)</em> and either modify your existing Workstation Group Policy or make a new one just for the deployment of this application depending on how you want to deploy it. By making a different GP to install, it can allow you deploy it just to a few machines, and only change the settings on those machines, where as the workstation method installs it to all workstations. This really up to the requirements of your environment. Either way you will need to look under <em>Group Policy Object</em> for your domain and create one or right click on one and edit it.<img src="http://www.waynezim.com/wp-content/uploads/2009/05/group-policy-software-installtion-300x100.png" alt="Group Policy Software Installation" title="Group Policy Software Installation" width="300" height="100" class="alignleft size-medium wp-image-93" /><br />Now use the Tree on the Left to browse to <em>Computer Configuration > Software Settings > Software Installation</em> and right click on <em>Software Installation</em> and select <em>New > Package&#8230;</em> It will now prompt you with an open dialog box, go and select the MSI that we created earlier. If all goes well you should end up with something like the screenshot shows to the left. If all goes well now the only thing you have to do is link it to the OUs that you want it to effect if you created a new one , or you let your workstation group policy deploy to all the workstations the next time they restart.
<p><strong>Firewall Configuration</strong><a href="http://www.waynezim.com/wp-content/uploads/2009/05/group-policy-firewall-config-ultravnc.png"><img src="http://www.waynezim.com/wp-content/uploads/2009/05/group-policy-firewall-config-ultravnc-300x226.png" alt="Group Policy Firewall Configuration for UltraVNC" title="Group Policy Firewall Configuration for UltraVNC" width="300" height="226" class="alignright size-medium wp-image-98" /></a><br />If you run a firewall on your machine you will need to allow port 5900 open. If you only running the default Windows Firewall you can configure this using the same group policy that you deployed UltraVNC with. Just go to <em>Computer Configuration > Administrative Templates > Network > Network Connections > Windows Firewall > Domain Profile</em> then select <em>Windows Firewall: Define port exceptions</em> select <em>Enabled</em> then click the <em>Show&#8230;</em> button and click <em>Add</em> and fill out the items to specification.
<p>For any other questions you have feel free to leave a comment I will be happy to assist you with the deployment.
<p>For any other detailed information about UltraVNC you should check out their website at <a href="http://www.uvnc.com">http://www.uvnc.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/05/how-to-deploy-vnc-using-group-policy/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Remove Temporary Files at Logoff</title>
		<link>http://www.waynezim.com/2009/04/remove-temporary-files-at-logoff/</link>
		<comments>http://www.waynezim.com/2009/04/remove-temporary-files-at-logoff/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 19:17:02 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[Logoff]]></category>
		<category><![CDATA[Temp]]></category>
		<category><![CDATA[Temp Files]]></category>
		<category><![CDATA[Temporary Files]]></category>
		<category><![CDATA[Temporary Internet Files]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=55</guid>
		<description><![CDATA[Over time users tend to open a lot of items programs that write little files to be used just once to print a document or a small setting for a program. These items build up over time and cause your computer to run slower due to your antivirus solution scanning it, your hard drive taking [...]]]></description>
			<content:encoded><![CDATA[<p>Over time users tend to open a lot of items programs that write little files to be used just once to print a document or a small setting for a program. These items build up over time and cause your computer to run slower due to your antivirus solution scanning it, your hard drive taking longer to find a free space of disk to write your new file or has to spend more time gathering up fragments of your file from in between these temp files. The solution here is pretty simple, these files need to go, and probably the easiest solution is the remove them when the user logs off. This doesn&#8217;t require anymore time for the user and typically isn&#8217;t a problem since most computers are logged on and off once a day.
<p>This script will remove the most common temporary folder for the user as well as remove any of the temporary internet files that they have gathered while surfing the web. When we implemented this script we noticed that the antivirus scan time and how many files it scanned were significantly reduced providing a better and faster workstation for your users. This script should be placed in the Group Policy for users as one of their logoff script.</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=55&amp;download=cleantemp.vbs">cleantemp.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p554"><td class="code" id="p55code4"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Const</span> TEMPORARY_INTERNET_FILES = &amp;H20&amp;
<span style="color: #000080;">dim</span> intDepth
&nbsp;
<span style="color: #000080;">Set</span> objShell = CreateObject(<span style="color: #800000;">&quot;Shell.Application&quot;</span>)
<span style="color: #000080;">Set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
<span style="color: #008000;">'Clean User Temporary Intenet Files
</span><span style="color: #000080;">Set</span> objNameSpace = objShell.Namespace(TEMPORARY_INTERNET_FILES)
<span style="color: #000080;">Set</span> objFolderItem = objNameSpace.Self
<span style="color: #000080;">set</span> objFolder=objFSO.GetFolder(objFolderItem.Path)
intDepth=0
RemoveFolder objFolder
&nbsp;
<span style="color: #008000;">'Clean User Temp Files
</span><span style="color: #000080;">Const</span> TemporaryFolder = 2
<span style="color: #000080;">Set</span> tempFolder = objFSO.GetSpecialFolder(TemporaryFolder)
RemoveFolder tempFolder
&nbsp;
&nbsp;
<span style="color: #000080;">sub</span> RemoveFolder(objFolder)
	<span style="color: #008000;">' Recursively remove files and folders
</span>	intDepth=intDepth+1
	<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;">for</span> <span style="color: #000080;">each</span> objFile <span style="color: #000080;">in</span> objFolder.Files
		objFile.Delete <span style="color: #000080;">true</span>
	<span style="color: #000080;">next</span>
	Err.Clear
	<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">goto</span> 0
	<span style="color: #000080;">for</span> <span style="color: #000080;">each</span> objSubfolder <span style="color: #000080;">in</span> objFolder.SubFolders
		RemoveFolder objSubFolder
	<span style="color: #000080;">next</span>
	intDepth=intDepth-1
	<span style="color: #000080;">if</span> intDepth&lt;&gt;0 <span style="color: #000080;">then</span><span style="color: #008000;">' Don't delete top-level folder
</span>		<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">resume</span> <span style="color: #000080;">next</span>
		objFolder.Delete <span style="color: #000080;">true</span> 
		err.Clear
		<span style="color: #000080;">on</span> <span style="color: #000080;">error</span> <span style="color: #000080;">goto</span> 0
	<span style="color: #000080;">end</span> <span style="color: #000080;">if</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/remove-temporary-files-at-logoff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote Shutdown / Logoff Script using WMI</title>
		<link>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/</link>
		<comments>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 13:21:23 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Force]]></category>
		<category><![CDATA[Logoff]]></category>
		<category><![CDATA[Restart]]></category>
		<category><![CDATA[Shutdown]]></category>
		<category><![CDATA[User Accounts]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=49</guid>
		<description><![CDATA[Have you ever been sitting at your desk working very hard trying to getting some business analytics report finished for your administrative team, only to be interrupted by the everyday user unable to log on the machine because someone else locked it. Then you have to get up and walk down there and manually login [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been sitting at your desk working very hard trying to getting some business analytics report finished for your administrative team, only to be interrupted by the everyday user unable to log on the machine because someone else locked it. Then you have to get up and walk down there and manually login and unlock the workstation. Well this is now a thing of the past for you if you have enabled WMI and have a domain or common credentials on your network. This script will simply allow you to unlock a workstation with out getting up from your desk. Unfortunately, I didn&#8217;t write this script but I use it about every other day to unlock a workstation. It has a few good options to allow you to either Logoff / Reboot / Shutdown the workstation. This can also be helpful when the user has locked up the PC and can&#8217;t get it to restart, you can send a command from the workstation you are at for that one to restart. In way you end up using this script it will only save you time, I found it to be very reliable and super fast for resolving the locked computer situation. Also, please browse though the code as it is well commented and you can get a greater understanding of how it exactly works.</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=49&amp;download=remoteshutdown.vbs">remoteshutdown.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p496"><td class="code" id="p49code6"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'/'|| Remote Shutdown.vbs
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Created by Harvey Hendricks, MCSE, A+,
</span><span style="color: #008000;">'|| March 2001
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| email: hhendrks@aramco.com
</span><span style="color: #008000;">'|| hhend@swbell.net
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Based on techniques and ideas from:
</span><span style="color: #008000;">'|| SMS admin, SMS Installer, &amp; WMI forums -&gt; http://www.myITforum.com/forums
</span><span style="color: #008000;">'|| Win32 Scripting -&gt; http://cwashington.netreach.net/
</span><span style="color: #008000;">'|| Microsoft Windows Script Technologies -&gt; http://msdn.microsoft.com/scripting
</span><span style="color: #008000;">'|| Microsoft Online Library -&gt; http://msdn.microsoft.com/library/default.asp
</span><span style="color: #008000;">'|| Microsoft VBScript 5.5 documentation
</span><span style="color: #008000;">'|| and Microsoft WMI SDK
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span><span style="color: #008000;">'|| SCRIPT LOGIC FLOW:
</span><span style="color: #008000;">'|| Collects computername from user, calls function to ping the computername
</span><span style="color: #008000;">'|| to determine if it is accessible, if not then display message and exit
</span><span style="color: #008000;">'|| otherwise continue.
</span><span style="color: #008000;">'|| Collects desired action to perform from the user, does error checking on
</span><span style="color: #008000;">'|| the input to determine if it is acceptable, if not then display message
</span><span style="color: #008000;">'|| and exit otherwise continue.
</span><span style="color: #008000;">'|| Set variables and output messages based on the action chosen. Calls
</span><span style="color: #008000;">'|| Win32Shutdown with the appropriate variable. Displays success message
</span><span style="color: #008000;">'|| and exits
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Uses WMI Win32Shutdown method from the Win32_OperatingSystem class
</span><span style="color: #008000;">'|| to perform different logoff / powerdown / reboot functions
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Testing found the following values to be effective on Win32Shutdown:
</span><span style="color: #008000;">'|| Action decimal binary
</span><span style="color: #008000;">'|| Logoff 0 0000
</span><span style="color: #008000;">'|| Force Logoff 4 0100
</span><span style="color: #008000;">'|| Reboot 2 0010
</span><span style="color: #008000;">'|| Force Reboot 6 0110
</span><span style="color: #008000;">'|| Powerdown 8 1000
</span><span style="color: #008000;">'|| Force Powerdown 12 1100
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| Notice that the third bit from the right appears to be the &quot;FORCE&quot; bit.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'|| A value of 1 will do a shutdown, ending at the &quot;It is safe to turn
</span><span style="color: #008000;">'|| off your computer&quot; screen. I have no use for this and did not test it.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||NOTES: - tested under Windows 2000 Pro. with ACPI compliant systems -
</span><span style="color: #008000;">'|| SHOULD work under Windows NT4 without modification IF the
</span><span style="color: #008000;">'|| system has compatible versions of WSH / WMI / VBscripting
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||Logoff / Powerdown / Reboot:
</span><span style="color: #008000;">'|| Does not work if a password protected screen saver is active or
</span><span style="color: #008000;">'|| there is data to save. Either way the system waits for user input.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'||Force Logoff / Force Powerdown / Force Reboot:
</span><span style="color: #008000;">'|| Does not work if a password protected screen saver is active, will wait
</span><span style="color: #008000;">'|| for user input. Otherwise will close open applications without saving data.
</span><span style="color: #008000;">'||
</span><span style="color: #008000;">'\/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</span>
&nbsp;
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ start function /\/\/\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\/\/\/\______________/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
</span><span style="color: #000080;">function</span> Ping(<span style="color: #000080;">byval</span> strName)
<span style="color: #000080;">dim</span> objFSO, objShell, objTempFile, objTS
<span style="color: #000080;">dim</span> sCommand, sReadLine
<span style="color: #000080;">dim</span> bReturn
&nbsp;
<span style="color: #000080;">set</span> objShell = WScript.CreateObject(<span style="color: #800000;">&quot;Wscript.Shell&quot;</span>)
<span style="color: #000080;">set</span> objFSO = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
<span style="color: #008000;">'Set default return value
</span>bReturn = <span style="color: #000080;">false</span>
&nbsp;
<span style="color: #008000;">'Create command line to ping and save results to a temp file
</span>sCommand = <span style="color: #800000;">&quot;cmd /c ping.exe -n 3 -w 1000 &quot;</span> &amp; strName &amp; <span style="color: #800000;">&quot; &gt; temp.txt&quot;</span>
&nbsp;
<span style="color: #008000;">'Execute the command
</span>objShell.run sCommand, 0, <span style="color: #000080;">true</span>
&nbsp;
<span style="color: #008000;">'Get the temp file
</span><span style="color: #000080;">set</span> objTempFile = objFSO.GetFile(<span style="color: #800000;">&quot;temp.txt&quot;</span>)
<span style="color: #000080;">set</span> objTS = objTempFile.OpenAsTextStream(1)
&nbsp;
<span style="color: #008000;">'Loop through the temp file to see if &quot;reply from&quot; is found,
</span><span style="color: #008000;">'if it is then the ping was successful
</span><span style="color: #000080;">do</span> <span style="color: #000080;">while</span> objTs.AtEndOfStream &lt;&gt; <span style="color: #000080;">true</span>
sReadLine = objTs.ReadLine
<span style="color: #000080;">if</span> instr(lcase(sReadLine), <span style="color: #800000;">&quot;reply from&quot;</span>) &gt; 0 <span style="color: #000080;">then</span>
bReturn = <span style="color: #000080;">true</span>
<span style="color: #000080;">exit</span> <span style="color: #000080;">do</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
<span style="color: #000080;">loop</span>
&nbsp;
<span style="color: #008000;">'Close temp file and release objects
</span>objTS.<span style="color: #000080;">close</span>
objTempFile.delete
<span style="color: #000080;">set</span> objTS = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objTempFile = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objShell = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> objFSO = <span style="color: #000080;">nothing</span>
&nbsp;
<span style="color: #008000;">'Return value
</span>Ping = bReturn
<span style="color: #000080;">end</span> <span style="color: #000080;">function</span>
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ end function /\/\/\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\/\/\/\______________/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
</span>
&nbsp;
&nbsp;
<span style="color: #008000;">'/\/\/\/\/\/\/\/\/\/\/\ Start Main body of script /\/\/\/\/\/\/\/\/\/\/\/'\/\/\/\/\/\/\/\/\/\/\/\_________________________/\/\/\/\/\/\/\/\/\/\/\/\/
</span><span style="color: #008000;">'Get computer name to operate on
</span>ComputerName=InputBox(<span style="color: #800000;">&quot;Enter the Machine name of the computer&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;you wish to Shutdown / Reboot / Logoff&quot;</span>, _
<span style="color: #800000;">&quot;Remote Shutdown / Reboot / Logoff&quot;</span>, _
<span style="color: #800000;">&quot;ComputerName&quot;</span>)
&nbsp;
<span style="color: #008000;">'if Cancel selected - exit
</span><span style="color: #000080;">If</span> (ComputerName = <span style="color: #800000;">&quot;&quot;</span>) <span style="color: #000080;">Then</span> Wscript.Quit
&nbsp;
<span style="color: #008000;">'change the name to uppercase
</span>ComputerName=UCase(ComputerName)
&nbsp;
<span style="color: #008000;">'ping the computername to see if it is accessible
</span>bPingtest = ping(Computername)
&nbsp;
<span style="color: #000080;">If</span> bPingtest = <span style="color: #000080;">FALSE</span> <span style="color: #000080;">Then</span>
y = msgbox (<span style="color: #800000;">&quot;'&quot;</span> &amp; ComputerName &amp; <span style="color: #800000;">&quot;' is not accessible!&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;It may be offline or turned off.&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;Check the name for a typo.&quot;</span> &amp; vbCRLF, _
vbCritical, ComputerName &amp; <span style="color: #800000;">&quot; NOT RESPONDING&quot;</span>)
Wscript.Quit
<span style="color: #000080;">end</span> <span style="color: #000080;">IF</span>
&nbsp;
<span style="color: #008000;">'Get the action desired
</span>Action=InputBox( _
<span style="color: #800000;">&quot;Select Action to perform on &quot;</span> &amp; ComputerName &amp; vbCRLF &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 1 - Logoff&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 2 - Force Logoff ( NO SAVE )&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 3 - Powerdown&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 4 - Force Powerdown ( NO SAVE )&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 5 - Reboot&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; 6 - Force Reboot ( NO SAVE )&quot;</span> &amp; vbCRLF &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot;NOTE:&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; Using Force will close windows&quot;</span> &amp; vbCRLF _
&amp; <span style="color: #800000;">&quot; without saving changes!&quot;</span>, _
<span style="color: #800000;">&quot;Select action to perform on &quot;</span> &amp; ComputerName, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
<span style="color: #008000;">'if Cancel selected - exit
</span><span style="color: #000080;">If</span> (Action = <span style="color: #800000;">&quot;&quot;</span>) <span style="color: #000080;">Then</span> Wscript.Quit
&nbsp;
<span style="color: #008000;">'error check input
</span><span style="color: #000080;">If</span> (INSTR(<span style="color: #800000;">&quot;1234567&quot;</span>,Action)=0) <span style="color: #000080;">OR</span> (Len(Action)&gt;1) <span style="color: #000080;">then</span>
y = msgbox(<span style="color: #800000;">&quot;Unacceptable input passed -- '&quot;</span> &amp; Action &amp; <span style="color: #800000;">&quot;'&quot;</span>, _
vbOKOnly + vbCritical, <span style="color: #800000;">&quot;That was SOME bad input!&quot;</span>)
Wscript.Quit
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
<span style="color: #008000;">' set flag to disallow action unless proper input is achieved, 1 =&gt; go 0 =&gt; nogo
</span>flag = 0
&nbsp;
<span style="color: #008000;">'set variables according to computername and action
</span><span style="color: #000080;">Select</span> <span style="color: #000080;">Case</span> Action
<span style="color: #000080;">Case</span> 1 <span style="color: #008000;">'Logoff
</span>x = 0
strAction = <span style="color: #800000;">&quot;Logoff sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 2 <span style="color: #008000;">'Force Logoff
</span>x = 4
strAction = <span style="color: #800000;">&quot;Force Logoff sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 3 <span style="color: #008000;">'Powerdown
</span>x = 8
strAction = <span style="color: #800000;">&quot;Powerdown sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 4 <span style="color: #008000;">'Force Powerdown
</span>x = 12
strAction = <span style="color: #800000;">&quot;Force Powerdown sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 5 <span style="color: #008000;">'Reboot
</span>x = 2
strAction = <span style="color: #800000;">&quot;Reboot sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 6 <span style="color: #008000;">'Force Reboot
</span>x = 6
strAction = <span style="color: #800000;">&quot;Force Reboot sent to &quot;</span> &amp; ComputerName
flag = 1
<span style="color: #000080;">Case</span> 7 <span style="color: #008000;">'Test dialog boxes
</span>y = msgbox(<span style="color: #800000;">&quot;Test complete&quot;</span>, vbOKOnly + vbInformation, <span style="color: #800000;">&quot;Dialog Box Test Complete&quot;</span>)
flag = 0
<span style="color: #000080;">Case</span> <span style="color: #000080;">Else</span> <span style="color: #008000;">'Default -- should never happen
</span>y = msgbox(<span style="color: #800000;">&quot;Error occurred in passing parameters.&quot;</span> _
&amp; vbCRLF &amp; <span style="color: #800000;">&quot; Passed '&quot;</span> &amp; Action &amp; <span style="color: #800000;">&quot;'&quot;</span>, _
vbOKOnly + vbCritical, <span style="color: #800000;">&quot;PARAMETER ERROR&quot;</span>)
flag = 0
<span style="color: #000080;">End</span> <span style="color: #000080;">Select</span>
&nbsp;
<span style="color: #008000;">'check flag
</span><span style="color: #008000;">' if equal 1 (TRUE) then perform Win32Shutdown action on remote PC
</span><span style="color: #008000;">' and display a confirmation message
</span><span style="color: #008000;">' if not equal 1 (FALSE) then skip the action and script ends
</span><span style="color: #000080;">if</span> flag <span style="color: #000080;">then</span>
<span style="color: #000080;">Set</span> OpSysSet=GetObject(<span style="color: #800000;">&quot;winmgmts:{(Debug,RemoteShutdown)}//&quot;</span> _
&amp; ComputerName &amp; <span style="color: #800000;">&quot;/root/cimv2&quot;</span>).ExecQuery( _
<span style="color: #800000;">&quot;Select * from Win32_OperatingSystem where Primary=true&quot;</span>)
<span style="color: #000080;">for</span> <span style="color: #000080;">each</span> OpSys <span style="color: #000080;">in</span> OpSysSet
OpSys.Win32Shutdown(x)
y = msgbox(strAction,vbOKOnly + vbInformation,<span style="color: #800000;">&quot;Mission Accomplished&quot;</span>)
<span style="color: #000080;">next</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">If</span>
&nbsp;
<span style="color: #008000;">'Release objects
</span><span style="color: #000080;">set</span> OpSys = <span style="color: #000080;">nothing</span>
<span style="color: #000080;">set</span> OpSysSet = <span style="color: #000080;">nothing</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/04/remote-shutdown-logoff-script-using-wmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing Active Directory Location</title>
		<link>http://www.waynezim.com/2009/04/showing-active-directory-location/</link>
		<comments>http://www.waynezim.com/2009/04/showing-active-directory-location/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 15:18:59 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></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=27</guid>
		<description><![CDATA[I have a very simple script for you today that will allow you to configure settings based on where a users and computers are within your Active Directory. This is very helpful when you are determining internet settings, file / printer connections and even desktop icons, but before you do all that you need a [...]]]></description>
			<content:encoded><![CDATA[<p>I have a very simple script for you today that will allow you to configure settings based on where a users and computers are within your Active Directory. This is very helpful when you are determining internet settings, file / printer connections and even desktop icons, but before you do all that you need a simple script to look up what your location / membership is in the directory. It will provide you with at path that is easily searched with string commands and can help diagnose why some users don&#8217;t get all the correct settings. This script returns to popup events, the first one gives you computer location: cn=nameofcomputer,ou=admin,dc=domain,dc=local and user location cn=username,ou=it,dc=domain,dc=local these are the strings you would search to determine who got which settings. Later I will show you how to use these settings to add icons, map drives, and map printers.</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=27&amp;download=ADLocation.vbs">ADLocation.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p278"><td class="code" id="p27code8"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Set</span> Network = WScript.CreateObject(<span style="color: #800000;">&quot;WScript.Network&quot;</span>)
<span style="color: #000080;">Set</span> objNetwork = CreateObject(<span style="color: #800000;">&quot;WScript.Network&quot;</span>) 
 compname = Network.ComputerName
 domname  = <span style="color: #800000;">&quot;domain&quot;</span>
&nbsp;
 <span style="color: #000080;">Set</span> oNet = CreateObject(<span style="color: #800000;">&quot;Wscript.Network&quot;</span>)
 <span style="color: #000080;">Set</span> oTrans = CreateObject(<span style="color: #800000;">&quot;NameTranslate&quot;</span>)
 oTrans.Init 1, domname
 oTrans.<span style="color: #000080;">Set</span> 3, domname &amp;<span style="color: #800000;">&quot;\&quot;</span>&amp; compname &amp;<span style="color: #800000;">&quot;$&quot;</span>
 sAdsPath = oTrans.<span style="color: #000080;">Get</span>(1)
 <span style="color: #000080;">Set</span> oNet = <span style="color: #000080;">Nothing</span>
 <span style="color: #000080;">Set</span> oTrans = <span style="color: #000080;">Nothing</span>
 sAdsPath = LCase(sAdsPath)
wscript.echo <span style="color: #800000;">&quot;Computer Location: &quot;</span> &amp; sAdsPath
&nbsp;
&nbsp;
<span style="color: #000080;">Set</span> objNetwork = CreateObject(<span style="color: #800000;">&quot;WScript.Network&quot;</span>) 
<span style="color: #000080;">Set</span> objUser = CreateObject(<span style="color: #800000;">&quot;ADSystemInfo&quot;</span>)
<span style="color: #000080;">Set</span> CurrentUser = GetObject(<span style="color: #800000;">&quot;LDAP://&quot;</span> &amp; objUser.UserName)
colGroups = CurrentUser.memberOf
userlocation = lcase(objUser.UserName)
&nbsp;
wscript.echo <span style="color: #800000;">&quot;User Location: &quot;</span>  &amp; userlocation</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/04/showing-active-directory-location/feed/</wfw:commentRss>
		<slash:comments>0</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="p1210"><td class="code" id="p12code10"><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>

