我正在尝试基于修改后的时间在Powershell中进行单向同步,但是下面的代码似乎无法正常工作。有什么想法吗?
$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 '<=')
{
$copyParams.Destination = $Folder2Path
}
Copy-Item @copyParams
}