0

I am trying to Sync a large number of files from a folder on the server into a cloudberry bucket for all files where the date today is the same as the last modified date for that file.

This codes syncs successfully, but it syncs all files in the folder, not just files with a lastwritetime after the $date, even when I changed the date to be a date a month in the future, all the files still synced.

I have attempted to find the solution online, but none of the solutions works for a $temp object of type CloudBerryLab.Explorer.PSSnapIn.Object.CloudFolder.

What am I doing wrong?

Add-PSSnapin CloudBerryLab.Explorer.PSSnapIn
Set-CloudOption -PathStyle VHost 
$date = Get-Date -Hour 0 -Minute 00 -Second 00
$s3 = Get-CloudS3Connection -Key XXXX -Secret XXXX
$source = Get-CloudFilesystemConnection | Select-CloudFolder -Path "//server1/XXXX/XXX"
$temp = $s3 | Select-CloudFolder -path "bucket/XXXX/"
$source | Copy-CloudSyncFolders $temp | Where-Object –Filter { $PSItem.LastWriteTime –ge $date}
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
  • 2
    I can't test as I don't use cloudberry, but it's likely that `where` needs to be used to filter the files before you pass them to the 'sync' cmd: `$source | Where-Object –Filter { $PSItem.LastWriteTime –ge $date} | Copy-CloudSyncFolders $temp` – henrycarteruk Oct 16 '18 at 09:40
  • That is better as no results are returned at all now, thank-you. I am guessing that means that $PSItem.LastWriteTime -ge $date is wrong. I think it must be the $PSItem.LastWriteTime that is wrong as it returns blank instead of a date. Any idea how to fix the filter? – EmmaChristian Oct 16 '18 at 13:04

0 Answers0