<?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; Cached</title>
	<atom:link href="http://www.waynezim.com/tag/cached/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.waynezim.com</link>
	<description>My World of Tech, Life and Anything Else</description>
	<lastBuildDate>Sun, 05 Feb 2012 05:35:31 +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>How to Remove Old Cached Roaming Profiles from Workstations</title>
		<link>http://www.waynezim.com/2009/06/how-to-remove-old-cached-roaming-profiles-from-workstations/</link>
		<comments>http://www.waynezim.com/2009/06/how-to-remove-old-cached-roaming-profiles-from-workstations/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 17:20:55 +0000</pubDate>
		<dc:creator>Wayne Zimmerman</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Cached]]></category>
		<category><![CDATA[Computer]]></category>
		<category><![CDATA[Profiles]]></category>
		<category><![CDATA[Roaming]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[vbs]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.waynezim.com/?p=238</guid>
		<description><![CDATA[Earlier this year I was tasked with cleaning up the workstations on our network to help reduce the amount of time needed for our daily virus scan to complete. One of the issues I took on was cleaning up old cached profiles from the use of roaming profiles. This was not something I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this year I was tasked with cleaning up the workstations on our network to help reduce the amount of time needed for our daily virus scan to complete. One of the issues I took on was cleaning up old cached profiles from the use of roaming profiles. This was not something I wanted to do manually for the 150 PCs that we have across our building, so I made a script that would look for profiles that had not been modified in the last 90 days and wasn&#8217;t a system account (localservice, networkservice, default user, all users). Also, an advantage of using a script to do this is it can produce a report of what it will remove without actually doing it. That way you can be sure that you are not deleting things that you do want to keep.</p>
<p>This script does depending on file and print sharing being turned on for the workstation so the script can access the administrative shares on each computer. It does make the assumption that your profiles are saved in the default windows location <em>C:\Documents and Settings\%username%</em> and that you are the administrator for the domain.</p>
<p><b>Configuration</b>
<ol>
<li>Be sure to update the LDAP string <code>'LDAP://OU=workstations,DC=subdomain,DC=domain,DC=com'</code> to match your Active Directory structure. The script needs to know where all the workstation are in Active Directory</li>
<li>Find <code>objConnection.Open "DomainController"</code> and modify the put your Domain Controller in place of <em>DomainController</em></li>
<li>Find <code>	OldProfile objRecordSet.Fields("Name").Value, "C:\deletedprofiles.csv"</code> and modify the filename to save the file where you and and named what you want, just be sure to leave the extension as CSV so it will open properly with your spreadsheet application.</li>
<li>Most Importantly &#8211; Comment out <code>fsoFolder.DeleteFolder objSubfolder, TRUE</code> if you just want a report of what it will delete when run, if not it is currently setup to remove the unwanted profiles</li>
</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=238&amp;download=RemoveOldCachedProfiles.vbs">RemoveOldCachedProfiles.vbs</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2382"><td class="code" id="p238code2"><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;shs-login&quot;</span>
&nbsp;
<span style="color: #000080;">Set</span> objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    <span style="color: #800000;">&quot;Select Name, Location from 'LDAP://OU=workstations,DC=subdomain,DC=domain,DC=com' &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
	OldProfile objRecordSet.Fields(<span style="color: #800000;">&quot;Name&quot;</span>).Value, <span style="color: #800000;">&quot;C:\deletedprofiles.csv&quot;</span>
    objRecordSet.MoveNext
<span style="color: #000080;">Loop</span>
&nbsp;
<span style="color: #000080;">Sub</span> OldProfile(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;">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> objShell = CreateObject(<span style="color: #800000;">&quot;Shell.Application&quot;</span>)
		<span style="color: #000080;">Set</span> fsoFolder = CreateObject(<span style="color: #800000;">&quot;Scripting.FileSystemObject&quot;</span>)
&nbsp;
		root = <span style="color: #800000;">&quot;\\&quot;</span> &amp; strComputer &amp;<span style="color: #800000;">&quot;\C$\Documents and Settings&quot;</span>
&nbsp;
		<span style="color: #000080;">Set</span> objFolder = fsoFolder.GetFolder(root)
		<span style="color: #000080;">Set</span> colSubfolders = objFolder.Subfolders
&nbsp;
			<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objSubfolder <span style="color: #000080;">in</span> colSubfolders
				<span style="color: #000080;">If</span> (lcase(objSubfolder.Name) &lt;&gt; <span style="color: #800000;">&quot;localservice&quot;</span> <span style="color: #000080;">AND</span> lcase(objSubfolder.Name) &lt;&gt; <span style="color: #800000;">&quot;networkservice&quot;</span>_
					<span style="color: #000080;">AND</span> lcase(objSubfolder.Name) &lt;&gt; <span style="color: #800000;">&quot;default user&quot;</span> <span style="color: #000080;">AND</span> lcase(objSubfolder.Name) &lt;&gt; <span style="color: #800000;">&quot;all users&quot;</span>) <span style="color: #000080;">then</span>
&nbsp;
						<span style="color: #000080;">If</span> (DateDiff(<span style="color: #800000;">&quot;D&quot;</span>, objSubfolder.DateLastModified, <span style="color: #000080;">Date</span>()) &gt; 90) <span style="color: #000080;">then</span>
							logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Online,Delete,&quot;</span> &amp; objSubfolder &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; objSubfolder.DateLastModified)
							fsoFolder.DeleteFolder objSubfolder, <span style="color: #000080;">TRUE</span>
						<span style="color: #000080;">else</span>
							logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Online,Active,&quot;</span> &amp; objSubfolder &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; objSubfolder.DateLastModified)
						<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
				<span style="color: #000080;">else</span>
					logStream.writeline(strComputer &amp; <span style="color: #800000;">&quot;,Online,System,&quot;</span> &amp; objSubfolder &amp; <span style="color: #800000;">&quot;,&quot;</span> &amp; objSubfolder.DateLastModified)
				<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
			<span style="color: #000080;">Next</span>
	<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></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.waynezim.com/2009/06/how-to-remove-old-cached-roaming-profiles-from-workstations/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

