ここでも、PowerShellで苦労しているルーキーです。PowerShellでフォルダーを比較し、デルタコンテンツを第3のフォルダーに書き込む
私は、DirAとDirBという2つのデータのフォルダを互いに比較する必要があります。 DirA(フォルダまたはデータの追加/削除)に加えられたすべての変更は、デルタフォルダにコピーする必要があります。フォルダDeltaは、コンテンツをDirBにコピーします。 DirBが常駐している切断されたネットワークにデータをアップロードするには、これを行う必要があります。私の問題は、データが確実にDeltaに、DeltaからDirBにコピーされていないようです。同期するデータは、数GBの
ここにmy codeです。正しい方向への助けや移動は感謝しています!
PS:私はComparing folders and content with PowerShellの例を見ましたが、コードを実行すると多くのランタイムエラーが発生します。私はそれが間違っている場所でそれを保持することはできません。
<# This script is being used to track changes between DirA and DirB. Changes will be copied to Delta folder and from here copied backwards to DirB to be in sync with DirA. Delta folder will be copied to an USB drive to be connected in disconnected network
#>
$src = Get-ChildItem -Path "C:\DirA\" -Recurse
$dst = Get-ChildItem -Path "D:\DirB" -Recurse
Do a compare of scr and dst and copy the changes to the folder D:\Delta Compare-Object -ReferenceObject $src -DifferenceObject $dst
-Property Name, Length | Where-Object {$_.SideIndicator -eq "<="} | ForEach-Object {
Copy-Item C:\DirA\$($_.name) -Destination "D:\Delta\WsusContent" -Recurse -force
}
Copy-Item D:\Delta\* D:\DirB\ -Recurse -Force
エラーを投稿できますか? –
完全なソースコードを含む最終的なソリューションですか? – Kiquenet