1
function Copy-File {
#.Synopsis
# copies only the difference of files existing in between source and destination
param([object]$source,[object]$destination)
# create destination if it's not there ...
mkdir $destination -Force -ErrorAction SilentlyContinue
$source1 = Get-ChildItem -Path $source
$destination1 = Get-ChildItem -Path $destination
$filediff = Compare-Object -ReferenceObject $source1 -DifferenceObject $destination1
$filediff | foreach {
$CopyParams = @{ 'Path' = $_.InputObject.FullName }
if ($_.SideIndicator -eq '<=') {
$CopyParams.Destination = $destination1
} else {
$CopyParams.Destination = $source1
}
Copy-Item @CopyParams
}
}
我想將它複製到用戶配置文件中的LocalAppData。試圖編寫一個功能來複制子目錄和文件的目錄,只有差異
您正在尋找['robocopy'(https://technet.microsoft.com/en-us/library/cc733145.aspx)。 –
'robocopy || headaches' – sodawillow