title: Powershell - Sync files based on modified time
body: <p>I'm trying to do a one way sync in Powershell based of of modified time but my code below does not seem to work. Any ideas?</p>
  
  <pre><code>$Folder1Path = 'D:\test'
  $Folder2Path = 'C:\test'
  
  
  $Folder1Files = Get-ChildItem -Path $Folder1Path
  $Folder2Files = Get-ChildItem -Path $Folder2Path
  
  $FileDiffs = Compare-Object -ReferenceObject $Folder1Files -DifferenceObject $Folder2Files -Property modifyTimeStamp
  
  $FileDiffs | foreach {
  $copyParams = @{
                      'Path' = $_.InputObject.FullName
                      }
                  if ($_.SideIndicator -eq '&lt;=')
                  {
                      $copyParams.Destination = $Folder2Path
                  }
  
                  Copy-Item @copyParams 
         }
  </code></pre>