scripts-n-stuff/Compare-Files.ps1
2023-12-08 14:45:42 +01:00

35 lines
928 B
PowerShell

# Example usage: Compare-Files.ps1 -filePath1 "C:\Users\dechert\keystores\case-creator-keystore.jks" -filePath2 "C:\Users\dechert\keystores\new\case-creator-keystore.jks"
param(
[string]$filePath1,
[string]$filePath2
)
function Compare-Files {
param(
[string]$path1,
[string]$path2
)
$hash1 = Get-FileHash -Path $path1
$hash2 = Get-FileHash -Path $path2
if ($hash1.Hash -eq $hash2.Hash) {
Write-Output "Files are identical."
} else {
Write-Output "Files are not identical."
}
}
# Check if both file paths are provided
if (-not $filePath1 -or -not $filePath2) {
Write-Host "Please provide both file paths."
} else {
# Check if the files exist
if (Test-Path $filePath1 && Test-Path $filePath2) {
Compare-Files -path1 $filePath1 -path2 $filePath2
} else {
Write-Host "One or both of the specified files do not exist."
}
}