すべてのファイルのハッシュを生成した後、フォルダー内のファイルを検証しようとしています。
ハッシュ出力を正常に取得できますが、これを機能させるのに問題があります。
# Compare the files inside both folders togethor
$Results = @( Compare-Object -ReferenceObject $( Hash-Folder -Folder $FolderSource ) -DifferenceObject $( Hash-Folder -Folder $FolderDestination ) -Property Name, Hash -IncludeEqual:$False | Sort-Object -Unique | Format-Table -HideTableHeaders | Out-String -Stream -Width 125 )
#If there are no differences, all is ok
If ( $Results -eq $NULL ) {
Write-host "All files verified successfully"
{ Else {
# There must be some differences, which side?
ForEach ( $Result in $Results ) {
If ( $Result.SideIndicator -eq '<=' ) {
Write-Host "This file is different in the source " $Result.Trim()
}
If ( $Result.SideIndicator -eq '=>' ) {
Write-Host "This file is different in the destination " $Result.Trim()
}
}
}
}