title: PowerShell: Change the timestamp (Date created) of a folder or file
body: <p>For PowerShell commands on Windows 10, I encounter a strange behaviour.</p>
  
  <p>To change a file's Date created, I use:</p>
  
  <pre><code>Get-ChildItem  C:\testFile1.txt | % {$_.CreationTime = '01/11/2005 06:00:36'}
  </code></pre>
  
  <p>To change a folder's Date created, I use:</p>
  
  <pre><code>Get-Item  C:\testFolder1 | % {$_.CreationTime = '01/11/2004 22:13:36'}
  </code></pre>
  
  <p>Those 2 commands work well on a regular basis on system partition C:\ or on desktop.</p>
  
  <p>The story is different if the folder exists on an external USB flash drive.</p>
  
  <p>(P.S. The command to change a file's timestamp still remains working on the external USB flash drive.)</p>
  
  <p>Suppose I try to change the Date created of a folder (not file) on an external USB flash drive:</p>
  
  <pre><code>Get-Item  U:\testFolder1 | % {$_.CreationTime = '01/11/2002 06:00:36'}
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre>
  Exception setting "CreationTime": "The process cannot access the file 'U:\testFolder1' because it is being used by another process."
  At line:1 char:31
  + ... et-Item  U:\testFolder1 | % {$_.CreationTime = '01/11/2002 06:00:36'}
  +                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
      + FullyQualifiedErrorId : ExceptionWhenSetting
  </pre>    
  
  <p>Digging further, I realize that the process is Windows 10's File Explorer, which prevents me from changing the timestamp. As long as I don't open File Explorer, I can use PowerShell to change the Date created of a folder on the USB flash drive.</p>
  
  <p>Is there anyway like .Dispose() to stop Windows 10's File Explorer from locking the folder without the need to close File Explorer every time?</p>