Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

mefanning (MIS) (OP)
26 Oct 11 20:50
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]::openread((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) }
    }
1RedOne (Programmer)
14 Dec 11 8:33
You just need to remove hyphens?

Here is a simple example.  You can use the -replace parameter of any variable to perform this operation.

PS C:\so> $numberswhashes = "12-45--5-5646-","770-97-606-","41124"
PS C:\so> $numberswhashes
12-45--5-5646-
770-97-606-
41124
PS C:\so> $numberswhashes -replace '-',''
124555646
77097606
41124

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close