process file-list

This commit is contained in:
Asif Bacchus 2020-06-20 07:43:27 -06:00
parent ac41f6fe48
commit f22fedf88c

19
sri.ps1
View File

@ -64,7 +64,7 @@ $hash = hashSHA $hashAlgo
if ($directory){ if ($directory){
# continue only if directory exists, otherwise exit with error # continue only if directory exists, otherwise exit with error
if (Test-Path -Path $directory){ if (Test-Path -Path $directory){
Write-Host "`nProcessing directory: $directory" -ForegroundColor Cyan Write-Host "Processing directory: $directory" -ForegroundColor Cyan
Get-ChildItem -Path $directory -Filter $filter | ForEach-Object({ Get-ChildItem -Path $directory -Filter $filter | ForEach-Object({
$hashValue = doHash $directory\$_ $hash $hashValue = doHash $directory\$_ $hash
if ($hashValue -ne 1){ if ($hashValue -ne 1){
@ -82,14 +82,25 @@ if ($directory){
# process file list, if specified # process file list, if specified
if ($files) { if ($files) {
Write-Host Write-Host "Processing files:" -ForegroundColor Cyan
foreach ($file in $files) { foreach ($file in $files) {
Write-Host "Processing $file" if (Test-Path -Path $file){
$hashValue = doHash $file $hash
if ($hashValue -ne 1){
Write-Host "$file --> $hashAlgo-$hashValue" -ForegroundColor Green
}
else {
Write-Host "$file --> unable to hash file" -ForegroundColor Red
}
}
else{
Write-Host "$file --> cannot find file" -ForegroundColor Red
}
} }
Write-Host
} }
# clean up and exit # clean up and exit
Write-Host
$hash.Dispose() $hash.Dispose()
exit 0 exit 0