I have a script that pulls the SHA1 hash off a file and sends the output to a logfile. Currently the output separates includes hyphens. I'm curious if I can edit the output as it is written to remove the hyphens, or if I need edit the logfile after it has been written to.
$Log = "C:\Temp\Log.txt"
Function Get-Hash{
$file = $Suspect
$algorithm = 'SHA1'
$fileStream = [system.io.file]:penread((resolve-path $file))
$hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm)
$hash = $hasher.ComputeHash($fileStream) #$fileStream.close()$fileStream.dispose()
[system.bitconverter]::tostring($hash)
}
get-process | ForEach-Object {$_.Modules} | foreach {
if (!$_.Company)
{$Suspect = $_.FileName
$HashOut = Get-Hash $Suspect
Add-Content $Log ($_.FileName + " " + $HashOut) }
}
$Log = "C:\Temp\Log.txt"
Function Get-Hash{
$file = $Suspect
$algorithm = 'SHA1'
$fileStream = [system.io.file]:penread((resolve-path $file))
$hasher = [System.Security.Cryptography.HashAlgorithm]::create($algorithm)
$hash = $hasher.ComputeHash($fileStream) #$fileStream.close()$fileStream.dispose()
[system.bitconverter]::tostring($hash)
}
get-process | ForEach-Object {$_.Modules} | foreach {
if (!$_.Company)
{$Suspect = $_.FileName
$HashOut = Get-Hash $Suspect
Add-Content $Log ($_.FileName + " " + $HashOut) }
}