title: Powershell Get-ChildItem seems to sometimes skip files
body: <p>I wrote a powershell script to upload files that are created in a local folder to SharePoint with Add-PnPFile.</p>
  <p>I loop the script every 20 seconds to check the folder for new files and then upload if the file is not on SharePoint yet. I use a Where-object to select only the last 5 minutes to not have to much files in the loop. (it needs to upload fast since flow is ERP-&gt;Local folder-&gt; SharePoint and users are waiting)</p>
  <p>This works like 95% of the time but sometimes it skips a files that is existing.</p>
  <pre><code>$Localfolder = &quot;D:\DATA&quot;
  $A_Files = Get-ChildItem -Path $Localfolder -Include @(&quot;*.pdf&quot;, &quot;*.csv&quot;) | Where-Object {$_.LastWriteTime -gt (Get-Date).AddMinutes(-5)}
  </code></pre>
  <p>If I stop the script and run in the same Powershell session, it doesn't show the file.
  If I open another powershell session and run the command it shows the file.</p>
  <p>Anyone know if there is caching or I'm missing something?</p>
  <blockquote>
  <p>PS C:\Users\rob_admin&gt; $PSVersionTable</p>
  </blockquote>
  <p>Name                           Value</p>
  <hr />
  <p>PSVersion                      5.1.14409.1018<br />
  PSEdition                      Desktop<br />
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}<br />
  BuildVersion                   10.0.14409.1018<br />
  CLRVersion                     4.0.30319.42000<br />
  WSManStackVersion              3.0<br />
  PSRemotingProtocolVersion      2.3<br />
  SerializationVersion           1.1.0.1</p>