##做者:Xiongpq ##時間:2015-06-10 18:50 ##版本:2.0 ##源文件目錄 ##源文件目錄的全部文件都會覆蓋目標目錄的同名文件,源文件目錄能夠在目標目錄內,不會循環覆蓋 $source = 'E:\Test_Target\Test_Source\' ##目標目錄,支持多個目錄 $target = 'E:\Test_Target\', 'D:\Test_Target' $sourceItem = Get-ChildItem -Path $source -recurse foreach ($sourceFileName in $sourceItem) { $targetItem = Get-ChildItem -Path $target -include $sourceFileName.Name -recurse foreach ($targetFileName in $targetItem) { if ($targetFileName.FullName -ne $sourceFileName.FullName){ Copy-Item -Path $sourceFileName.FullName -Destination $targetFileName.FullName -Force } } } Write-Host("DONE.....................")