 




<?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>PowerShell for Windows Admins &#187; File System</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/powershell/tag/file-system/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/powershell</link>
	<description>PowerShell and WMI: The fast and furious of windows administration.</description>
	<lastBuildDate>Fri, 24 May 2013 20:07:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Cleaning up the temp folder</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/cleaning-up-the-temp-folder/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/cleaning-up-the-temp-folder/#comments</comments>
		<pubDate>Fri, 08 Jun 2012 13:53:21 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[File System]]></category>
		<category><![CDATA[PowerShell 3]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/cleaning-up-the-temp-folder/</guid>
		<description><![CDATA[&#160; This post http://powershell.com/cs/blogs/tips/archive/2012/06/05/checking-size-of-downloads-folder.aspx go me thinking about the temp folder. Its one of those areas tucked away in your profile that just seems to get left to grow.&#160; Time to do something about it. $testdate = (Get-Date).AddDays(-10) $names = &#34;FXSAPIDebugLogFile.txt&#34;, &#34;hsperfdata_Richard&#34; ## assume TMP = TEMP $path = $env:TEMP Get-ChildItem -Path $path -File &#124; [...]]]></description>
				<content:encoded><![CDATA[<p>&#160;</p>
<p>This post</p>
<p><a title="http://powershell.com/cs/blogs/tips/archive/2012/06/05/checking-size-of-downloads-folder.aspx" href="http://powershell.com/cs/blogs/tips/archive/2012/06/05/checking-size-of-downloads-folder.aspx">http://powershell.com/cs/blogs/tips/archive/2012/06/05/checking-size-of-downloads-folder.aspx</a></p>
<p>go me thinking about the temp folder. Its one of those areas tucked away in your profile that just seems to get left to grow.&#160; Time to do something about it.</p>
<pre><span style="color: #ff4500">$testdate</span> <span style="color: #a9a9a9">=</span> <span style="color: #000000">(</span><span style="color: #0000ff">Get-Date</span><span style="color: #000000">)</span><span style="color: #a9a9a9">.</span><span style="color: #000000">AddDays</span><span style="color: #000000">(</span><span style="color: #800080">-10</span><span style="color: #000000">)</span>            
<span style="color: #ff4500">$names</span> <span style="color: #a9a9a9">=</span> <span style="color: #8b0000">&quot;FXSAPIDebugLogFile.txt&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;hsperfdata_Richard&quot;</span>            
            
<span style="color: #006400">## assume TMP = TEMP</span>            
<span style="color: #ff4500">$path</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$env:TEMP</span>            
            
<span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$path</span> <span style="color: #000080">-File</span>  <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">where</span> <span style="color: #8a2be2">LastWriteTime</span> <span style="color: #000080">-lt</span> <span style="color: #ff4500">$testdate</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">where</span> <span style="color: #8a2be2">Name</span> <span style="color: #000080">-NotIn</span> <span style="color: #ff4500">$names</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Remove-Item</span> <span style="color: #000080">-Force</span> <span style="color: #006400">#-WhatIf</span>            
            
<span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$path</span> <span style="color: #000080">-Directory</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">where</span> <span style="color: #8a2be2">LastWriteTime</span> <span style="color: #000080">-lt</span> <span style="color: #ff4500">$testdate</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">where</span> <span style="color: #8a2be2">Name</span> <span style="color: #000080">-NotIn</span> <span style="color: #ff4500">$names</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">Remove-Item</span> <span style="color: #000080">-Force</span> <span style="color: #000080">-Recurse</span> <span style="color: #006400">#-WhatIf</span></pre>
<p>I decide to use some of the new functionality in PowerShell v3 and separate the file and folder processing so I could play (er experiment) with some of the new parameters in&#160; Get-ChildItem </p>
<p>Get-ChildItem [-Attributes &lt;FileAttributes]&gt;] [-Directory] [-File] [-Force] [-Hidden] [-ReadOnly] [-System]<br />
  <br />[-UseTransaction] [&lt;CommonParameters&gt;]</p>
<p>These are a separate parameter set which means that -exclude and –include don’t work with them.</p>
<p>So start by creating a date to test against. Anything older than this will be deleted. Define a few names of things that have to be left alone (these will probably be different on your system) and set the path. I’ve assumed that the TEMP and TMP environmental variables point to the same path. if your system is different put the rest of the code into a foreach loop to iterate through the two variables.</p>
<p>Starting with files we get all the files in the root of TEMP. The –File parameter means we only look at files – folders are automatically excluded.</p>
<p>I’ve then used two where statements. Now the obvious comment is that I could combine them but if I do that I have to check each file for its age and then if its name is in my exclusion list. This way I test for age and immediately filter out any file that it is too young. Then I test for name. Doing it this way gives a small performance increase if you have a lot of young files.</p>
<p>I then pass the files to Remove-Item to delete.</p>
<p>The directories are processed in a similar manner except that we use –Directory on Get-ChildItem and add –Recurse to the Remove-Item call so that non-empty folders are removed.</p>
<p>Next move is to make this a scheduled task using the new PowerShell scheduled task cmdlets.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/cleaning-up-the-temp-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Folder sizes</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/folder-sizes/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/folder-sizes/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 21:14:24 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[File System]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/folder-sizes/</guid>
		<description><![CDATA[Question on the forums related to folder sizes and last write time Get-ChildItem -Path &#34;C:\PersonalData\MyBooks\PowerShell and WMI&#34; -Recurse &#124; where { $_.PSIsContainer} &#124; foreach { $size = Get-ChildItem -Path $_.FullName &#124; measure -Sum Length &#124; select -ExpandProperty Sum Add-Member -InputObject $($_) -MemberType NoteProperty -Name Size -Value $size $_ &#124; select Fullname, LastWriteTime, @{N=&#34;Size(MB)&#34;; E={[math]::Round(($_.Size/1mb), 2)}} [...]]]></description>
				<content:encoded><![CDATA[<p>Question on the forums related to folder sizes and last write time</p>
<pre><span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #8b0000">&quot;C:\PersonalData\MyBooks\PowerShell and WMI&quot;</span> <span style="color: #000080">-Recurse</span> <span style="color: #a9a9a9">|</span>             
<span style="color: #0000ff">where</span> <span style="color: #000000">{</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSIsContainer</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
 <span style="color: #ff4500">$size</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">FullName</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">measure</span> <span style="color: #000080">-Sum</span> <span style="color: #8a2be2">Length</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">Sum</span>            
             
 <span style="color: #0000ff">Add-Member</span> <span style="color: #000080">-InputObject</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #000000">)</span> <span style="color: #000080">-MemberType</span> <span style="color: #8a2be2">NoteProperty</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">Size</span> <span style="color: #000080">-Value</span> <span style="color: #ff4500">$size</span>            
            
 <span style="color: #ff4500">$_</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">select</span> <span style="color: #8a2be2">Fullname</span><span style="color: #a9a9a9">,</span> <span style="color: #8a2be2">LastWriteTime</span><span style="color: #a9a9a9">,</span> <span style="color: #000000">@{</span><span style="color: #000000">N</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;Size(MB)&quot;</span><span style="color: #000000">;</span> <span style="color: #000000">E</span><span style="color: #a9a9a9">=</span><span style="color: #000000">{</span><span style="color: #008080">[math]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Round</span><span style="color: #000000">(</span><span style="color: #000000">(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Size</span><span style="color: #a9a9a9">/</span><span style="color: #800080">1mb</span><span style="color: #000000">)</span><span style="color: #a9a9a9">,</span> <span style="color: #800080">2</span><span style="color: #000000">)</span><span style="color: #000000">}</span><span style="color: #000000">}</span>            
<span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Format-Table</span> <span style="color: #000080">-AutoSize</span> <span style="color: #000080">-Wrap</span></pre>
<p>Unfortunately the object returned by get-ChildItem doesn’t include folder size. So we loop through each folder &amp; get the sum of its contents. The size value is added to the folder object and Fullname, LastwriteTime and size displayed.&#160; The size is recalculated to megabytes. Substitute your favourite size </p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/folder-sizes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count of files in a folder</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/count-of-files-in-a-folder/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/count-of-files-in-a-folder/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 20:05:14 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[File System]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/count-of-files-in-a-folder/</guid>
		<description><![CDATA[I was recently left a comment of a post http://richardspowershellblog.wordpress.com/2009/11/30/updating-access-data/ asking about the how to get the count of files in a folder There are a number of solutions including dropping back to the FileSystem object from VBscript If we want just a PowerShell option function filecount { param ( [string]$path ) if (-not (Test-Path [...]]]></description>
				<content:encoded><![CDATA[<p>I was recently left a comment of a post</p>
<p><a title="http://richardspowershellblog.wordpress.com/2009/11/30/updating-access-data/" href="http://richardspowershellblog.wordpress.com/2009/11/30/updating-access-data/">http://richardspowershellblog.wordpress.com/2009/11/30/updating-access-data/</a></p>
<p>asking about the how to get the count of files in a folder</p>
<p>There are a number of solutions including dropping back to the FileSystem object from VBscript</p>
<p>If we want just a PowerShell option</p>
<pre><span style="color: #00008b">function</span> <span style="color: #8a2be2">filecount</span> <span style="color: #000000">{</span>            
<span style="color: #00008b">param</span> <span style="color: #000000">(</span>            
 <span style="color: #008080">[string]</span><span style="color: #ff4500">$path</span>            
<span style="color: #000000">)</span>            
 <span style="color: #00008b">if</span> <span style="color: #000000">(</span><span style="color: #a9a9a9">-not</span> <span style="color: #000000">(</span><span style="color: #0000ff">Test-Path</span> <span style="color: #ff4500">$path</span><span style="color: #000000">)</span><span style="color: #000000">)</span><span style="color: #000000">{</span><span style="color: #00008b">Throw</span> <span style="color: #8b0000">&quot;Path: $path not found&quot;</span><span style="color: #000000">}</span>            
             
 <span style="color: #ff4500">$count</span> <span style="color: #a9a9a9">=</span> <span style="color: #800080">0</span>            
 <span style="color: #ff4500">$count</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$path</span> <span style="color: #a9a9a9">|</span>             
          <span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #a9a9a9">!</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSIsContainer</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>             
          <span style="color: #0000ff">Measure-Object</span> <span style="color: #a9a9a9">|</span>            
          <span style="color: #0000ff">select</span> <span style="color: #000080">-ExpandProperty</span> <span style="color: #8a2be2">count</span>            
                      
 <span style="color: #0000ff">Get-Item</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$path</span> <span style="color: #a9a9a9">|</span>             
 <span style="color: #0000ff">select</span> <span style="color: #8a2be2">PSDrive</span><span style="color: #a9a9a9">,</span>             
 <span style="color: #000000">@{</span><span style="color: #000000">N</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;Parent&quot;</span><span style="color: #000000">;</span> <span style="color: #000000">E</span><span style="color: #a9a9a9">=</span><span style="color: #000000">{</span><span style="color: #000000">(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSParentPath</span> <span style="color: #a9a9a9">-split</span> <span style="color: #8b0000">&quot;FileSystem::&quot;</span><span style="color: #000000">)</span><span style="color: #a9a9a9">[</span><span style="color: #800080">1</span><span style="color: #a9a9a9">]</span><span style="color: #000000">}</span><span style="color: #000000">}</span><span style="color: #a9a9a9">,</span>            
 <span style="color: #8a2be2">Name</span><span style="color: #a9a9a9">,</span>            
 <span style="color: #000000">@{</span><span style="color: #000000">N</span><span style="color: #a9a9a9">=</span><span style="color: #8b0000">&quot;FileCount&quot;</span><span style="color: #000000">;</span> <span style="color: #000000">E</span><span style="color: #a9a9a9">=</span><span style="color: #000000">{</span><span style="color: #ff4500">$count</span><span style="color: #000000">}</span><span style="color: #000000">}</span>            
             
 <span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$path</span> <span style="color: #a9a9a9">|</span>             
 <span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSIsContainer</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>            
 <span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
   <span style="color: #0000ff">filecount</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Fullname</span><span style="color: #000000">)</span>            
 <span style="color: #000000">}</span>            
            
<span style="color: #000000">}</span>             
            
<span style="color: #0000ff">filecount</span> <span style="color: #8b0000">&quot;c:\scripts&quot;</span></pre>
<p>Supply a path to the top level folder for the filecount function</p>
<p>It will test if the folder exists &amp; complain if it doesn’t.</p>
<p>We can then count the files in the folder using PSISContainer to filter out any subfolders and measure-object to perform the count.</p>
<p>Get-item is used on the path and piped into select where we split out the parent path and add the file count (that count be done with add-member as well</p>
<p>Get-ChildItem is used on the path and only folders are passed. The path of each subfolder is passed to the filecount function.&#160; </p>
<p>A function calling itself like this known as recursion</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/count-of-files-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing folder creation date</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/changing-folder-creation-date/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/changing-folder-creation-date/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 11:53:02 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[File System]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/changing-folder-creation-date/</guid>
		<description><![CDATA[A question on the forum asked about setting creation date on folders after they have been copied to match the source folder. I created a source folder with three folders and modified the creation dates Set-ItemProperty -Path c:\testsource\folder1 -Name CreationTime -Value ((get-date).adddays(-90)) Set-ItemProperty -Path c:\testsource\folder2 -Name CreationTime -Value ((get-date).adddays(-127)) Set-ItemProperty -Path c:\testsource\folder3 -Name CreationTime -Value [...]]]></description>
				<content:encoded><![CDATA[<p>A question on the forum asked about setting creation date on folders after they have been copied to match the source folder.</p>
<p>I created a source folder with three folders and modified the creation dates</p>
<p>Set-ItemProperty -Path c:\testsource\folder1 -Name CreationTime -Value ((get-date).adddays(-90))    <br />Set-ItemProperty -Path c:\testsource\folder2 -Name CreationTime -Value ((get-date).adddays(-127))     <br />Set-ItemProperty -Path c:\testsource\folder3 -Name CreationTime -Value ((get-date).adddays(-192))</p>
<p>&#160;</p>
<p>I then created a file </p>
<p>dir c:\scripts |out-file -FilePath test.txt</p>
<p>and copied it into each folder</p>
<p>&#160;</p>
<p>The copy of the folders and their contents is achieved like this</p>
<p>Copy-Item -Path c:\testsource\* -Destination c:\testtarget -Force –Recurse</p>
<p>&#160;</p>
<p>Our source looks like this</p>
<p>PS&gt; Get-ChildItem -Path c:\testsource | where {$_.PSIsContainer} | ft&#160; Fullname, CreationTime -a</p>
<p>FullName&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CreationTime    <br />&#8212;&#8212;&#8211;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;&#8212;     <br />C:\testsource\Folder1&#160;&#160; 13/11/2011 11:26:35     <br />C:\testsource\Folder2&#160;&#160; 07/10/2011 11:27:12     <br />C:\testsource\Folder3&#160;&#160; 03/08/2011 11:27:27</p>
<p><font size="2" face="Courier New"></font></p>
<p>&#160;</p>
<p>and the target looks like this</p>
<p>PS&gt; Get-ChildItem -Path c:\testtarget | where {$_.PSIsContainer} | ft&#160; Fullname, CreationTime -a</p>
<p>FullName&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CreationTime    <br />&#8212;&#8212;&#8211;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;&#8212;     <br />C:\testtarget\Folder1&#160;&#160; 11/02/2012 11:34:25     <br />C:\testtarget\Folder2&#160;&#160; 11/02/2012 11:34:25     <br />C:\testtarget\Folder3&#160;&#160; 11/02/2012 11:34:25</p>
<p>&#160;</p>
<p>So our job is to change the creationtime property on the target folders</p>
<p>&#160;</p>
<pre><span style="color: #0000ff">Get-ChildItem</span> <span style="color: #000080">-Path</span> <span style="color: #8a2be2">c:\testsource</span> <span style="color: #000080">-Recurse</span> <span style="color: #a9a9a9">|</span>             
<span style="color: #0000ff">where</span> <span style="color: #000000">{</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSIsContainer</span><span style="color: #000000">}</span> <span style="color: #a9a9a9">|</span>            
<span style="color: #0000ff">foreach</span> <span style="color: #000000">{</span>            
 <span style="color: #ff4500">$newfolder</span> <span style="color: #a9a9a9">=</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">Fullname</span> <span style="color: #a9a9a9">-replace</span> <span style="color: #8b0000">&quot;Testsource&quot;</span><span style="color: #a9a9a9">,</span> <span style="color: #8b0000">&quot;Testtarget&quot;</span>            
            
 <span style="color: #0000ff">Set-ItemProperty</span> <span style="color: #000080">-Path</span> <span style="color: #ff4500">$newfolder</span> <span style="color: #000080">-Name</span> <span style="color: #8a2be2">CreationTime</span> <span style="color: #000080">-Value</span> <span style="color: #000000">$(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">CreationTime</span><span style="color: #000000">)</span>            
<span style="color: #000000">}</span></pre>
<p>&#160;</p>
<p>Just loop through the source folders – change the path to match the target and set the CreationTime</p>
<p>&#160;</p>
<p>We can then test the results</p>
<p>PS&gt; Get-ChildItem -Path c:\testtarget | where {$_.PSIsContainer} | ft&#160; Fullname, CreationTime -a</p>
<p>FullName&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CreationTime<br />
  <br />&#8212;&#8212;&#8211;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8212;&#8212;&#8212;&#8212; </p>
<p>C:\testtarget\Folder1&#160;&#160; 13/11/2011 11:26:35 </p>
<p>C:\testtarget\Folder2&#160;&#160; 07/10/2011 11:27:12 </p>
<p>C:\testtarget\Folder3&#160;&#160; 03/08/2011 11:27:27</p>
<p>&#160;</p>
<p>Job done</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/changing-folder-creation-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting files older than a certain date</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/deleting-files-older-than-a-certain-date/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/deleting-files-older-than-a-certain-date/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 11:52:20 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[File System]]></category>
		<category><![CDATA[PowerShell v2]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/deleting-files-older-than-a-certain-date/</guid>
		<description><![CDATA[A question on the ITKE forums asked how files older than a certain date (in this case two months) could be deleted without touching younger files. 001 002 003 $date&#160;=&#160;(Get-Date).AddMonths(-2) Get-ChildItem&#160;-Path&#160;c:\scripts&#160;&#124;&#160;where&#160;{!$_.PSIsContainer}&#160;&#124; foreach&#160;{if&#160;($_.LastWriteTime&#160;-lt&#160;$date){Remove-Item&#160;$_&#160;-whatif}} Simply remove the –whatif parameter for the delete to actually happen]]></description>
				<content:encoded><![CDATA[<p>A question on the ITKE forums asked how files older than a certain date (in this case two months) could be deleted without touching younger files.</p>
<div style="padding-bottom: 5px;padding-left: 5px;width: 542px;padding-right: 5px;font-family: consolas,lucida console;height: 102px;font-size: 10pt;padding-top: 5px">
<table border="0" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<td valign="top">
<div style="padding-bottom: 5px;padding-left: 5px;padding-right: 5px;font-family: consolas,lucida console;font-size: 10pt;padding-top: 5px">001             <br />002              <br />003              </div>
</td>
<td valign="top" nowrap="nowrap">
<div style="padding-bottom: 5px;padding-left: 5px;padding-right: 5px;font-family: consolas,lucida console;font-size: 10pt;padding-top: 5px"><span style="color: #ff4500">$date</span><span style="color: #000000">&#160;</span><span style="color: #a9a9a9">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">(</span><span style="color: #0000ff">Get-Date</span><span style="color: #000000">)</span><span style="color: #a9a9a9">.</span><span style="color: #000000">AddMonths</span><span style="color: #000000">(</span><span style="color: #800080">-2</span><span style="color: #000000">)</span>              <br /><span style="color: #0000ff">Get-ChildItem</span><span style="color: #000000">&#160;</span><span style="color: #000080">-Path</span><span style="color: #000000">&#160;</span><span style="color: #8a2be2">c:\scripts</span><span style="color: #000000">&#160;</span><span style="color: #a9a9a9">|</span><span style="color: #000000">&#160;</span><span style="color: #0000ff">where</span><span style="color: #000000">&#160;</span><span style="color: #000000">{</span><span style="color: #a9a9a9">!</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">PSIsContainer</span><span style="color: #000000">}</span><span style="color: #000000">&#160;</span><span style="color: #a9a9a9">|</span>              <br /><span style="color: #0000ff">foreach</span><span style="color: #000000">&#160;</span><span style="color: #000000">{</span><span style="color: #00008b">if</span><span style="color: #000000">&#160;</span><span style="color: #000000">(</span><span style="color: #ff4500">$_</span><span style="color: #a9a9a9">.</span><span style="color: #000000">LastWriteTime</span><span style="color: #000000">&#160;</span><span style="color: #a9a9a9">-lt</span><span style="color: #000000">&#160;</span><span style="color: #ff4500">$date</span><span style="color: #000000">)</span><span style="color: #000000">{</span><span style="color: #0000ff">Remove-Item</span><span style="color: #000000">&#160;</span><span style="color: #ff4500">$_</span><span style="color: #000000">&#160;</span><span style="color: #000080">-whatif</span><span style="color: #000000">}</span><span style="color: #000000">}</span> </div>
</td>
</tr>
</tbody>
</table></div>
<p>Simply remove the –whatif parameter for the delete to actually happen</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/deleting-files-older-than-a-certain-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How big&#8217;s my dit</title>
		<link>http://itknowledgeexchange.techtarget.com/powershell/how-bigs-my-dit/</link>
		<comments>http://itknowledgeexchange.techtarget.com/powershell/how-bigs-my-dit/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 18:51:47 +0000</pubDate>
		<dc:creator>Richard Siddaway</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[File System]]></category>
		<category><![CDATA[PowerShell v2]]></category>
		<category><![CDATA[WMI]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/powershell/how-bigs-my-dit/</guid>
		<description><![CDATA[The ntds.dit file is used to store Active Directory data on a domain controller. Knowing how big this file is getting is a useful piece if information. One way is to log on to each domain controller and test the size using Windows explorer. A better way is to use WMI PS&#62; &#8220;server02&#8243;, &#8220;dc02&#8243; &#124; [...]]]></description>
				<content:encoded><![CDATA[<p>The ntds.dit file is used to store Active Directory data on a domain controller. Knowing how big this file is getting is a useful piece if information. One way is to log on to each domain controller and test the size using Windows explorer.</p>
<p>A better way is to use WMI</p>
<p>PS&gt; &#8220;server02&#8243;, &#8220;dc02&#8243; | foreach {Get-WmiObject -Class CIM_LogicalFile `</p>
<p>-Filter &#8220;Name=&#8217;c:\\Windows\\NTDS\\ntds.dit&#8217;&#8221; -computername $_ }  |</p>
<p>Format-table CSname, FileSize  -AutoSize</p>
<p>CSname        FileSize<br />
&#8212;&#8212;                 &#8212;&#8212;&#8211;<br />
SERVER02   41959424<br />
DC02             41959424</p>
<p>If the file is in different places on different machines then put the server name and the location into a csv file.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/powershell/how-bigs-my-dit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
