This commit is contained in:
Nathan
2025-12-19 11:50:02 -07:00
parent 4d1b554f8f
commit 92e5e57f19
2 changed files with 679 additions and 22 deletions

View File

@@ -30,26 +30,22 @@ if ($null -eq $allFiles -or $allFiles.Count -eq 0) {
Write-Host "Found $($allFiles.Count) files to process." -ForegroundColor Green
# Calculate checksums for all files
Write-Host "Calculating checksums (this may take a while)..." -ForegroundColor Yellow
$filesWithChecksums = @()
$fileCount = 0
foreach ($file in $allFiles) {
$fileCount++
if ($fileCount % 50 -eq 0) {
Write-Host " Processed $fileCount / $($allFiles.Count) files..." -ForegroundColor Gray
}
# Calculate checksums for all files using parallel processing
Write-Host "Calculating checksums using parallel processing (this may take a while)..." -ForegroundColor Yellow
$throttleLimit = [Math]::Max(1, [Environment]::ProcessorCount)
$parallelScriptBlock = {
try {
$hash = Get-FileHash -Path $file.FullName -Algorithm SHA256
$filesWithChecksums += [PSCustomObject]@{
File = $file
$hash = Get-FileHash -Path $_.FullName -Algorithm SHA256
[PSCustomObject]@{
File = $_
Hash = $hash.Hash
}
} catch {
Write-Warning "Failed to calculate checksum for: $($file.FullName) - $($_.Exception.Message)"
Write-Warning "Failed to calculate checksum for: $($_.FullName) - $($_.Exception.Message)"
$null
}
}
$filesWithChecksums = $allFiles | ForEach-Object -Parallel $parallelScriptBlock -ThrottleLimit $throttleLimit | Where-Object { $null -ne $_ }
Write-Host "Checksum calculation complete." -ForegroundColor Green