Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!
  • Students Click Here

*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.

Students Click Here

Remove Hyphens from output

Remove Hyphens from output

Remove Hyphens from output

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()



get-process | ForEach-Object {$_.Modules} | foreach {

    if (!$_.Company)
    {$Suspect = $_.FileName
    $HashOut = Get-Hash $Suspect
    Add-Content $Log ($_.FileName + " " + $HashOut) }

RE: Remove Hyphens from output

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
PS C:\so> $numberswhashes -replace '-',''

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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