title: Compare-Object Delete File if file does not exist on source
body: <p>I have this PowerShell code that compares 2 directories and removes files if the files no longer exist in the source directory.</p>
  
  <p>For example say I have Folder 1 &amp; Folder 2. I want to compare Folder 1 with Folder 2, If a file doesn't exist anymore in Folder 1 it will remove it from Folder 2.</p>
  
  <p>this code works ok but I have a problem where it also picks up file differences on the date/time. I only want it to pick up a difference if the file doesn't exist anymore in Folder 1.</p>
  
  <pre><code>  Compare-Object $source $destination -Property Name  -PassThru | Where-Object {$_.SideIndicator -eq "=&gt;"} | % {
          if(-not $_.FullName.PSIsContainer) {
              UPDATE-LOG  "File: $($_.FullName) has been removed from source"
              Remove-Item -Path $_.FullName -Force -ErrorAction SilentlyContinue
          }
      }
  </code></pre>
  
  <p>Is there an extra Where-Object {$file1 &lt;> $file2} or something like that.?</p>