So I have two servers and two folders which should contain the same *.jar, meaning same hash. I am trying to compare ex 2 jars from first to the 2 jars from the second server. Using the following always return Different because it is not taking each file separately.
$FileHash1 = (Get-FileHash '\\server1\c$\some_folder\*jar').Hash
$FileHash2 = (Get-FileHash '\\server2\c$\some_folder\*jar').Hash
if($FileHash1 -eq $FileHash2) {
Write-Host "Equal"
} Else {
Write-Host "Different"
}
I understand that somewhere there should be foreach but cant seem to find how exactly to make it work.