How to prevent carriage return being copied to clipboard in Powershell?

Posted by user610209 on Super User See other posts from Super User or by user610209
Published on 2013-06-25T20:04:49Z Indexed on 2013/06/27 16:23 UTC
Read the original article Hit count: 129

Filed under:

I have a powershell script that is hashing the MAC address, then posting it into a file and a clipboard.

$hash = [System.BitConverter]::ToString($md5.ComputeHash($utf8.GetBytes($MAC)))
$hash | clip
$hash | Out-File $Env:USERPROFILE\Desktop\this.txt 

The issue I am having is that a carriage return is being exported to the clipboard. I don't want that.

Is there a way of stopping that happening?

Additional info - When I paste the text that is on the clipboard into a hex editor I see 0D0A

The clipboard function would be fine if I could just loose that some how? Thanks

© Super User or respective owner

Related posts about powershell