Get-ChildItem "C:\Dir1" | Where-Object {-Not $_.PsIscontainer} | % {
$file1 = $_.FullName;
$file2 = $file1 -replace ("C:\Dir", "C:\Dir2")
If (Test-Path $file2)
{
$file1s=$_.Length
$file2s=(Get-Item $file2).Length
if ($file1s -gt $file2s)
{
Copy-Item $file1 "C:\Dir2" -Force
}
}
else
{
Copy-Item $file1 "C:\Dir2"
}
}