3 ms·
Ask and ye shall receive (in powershell form): $fName = "last.exe" $fContent = get-content $fName $fContentBytes = [System.Text.Encoding]::UTF8.G
by iuguy 13y ago
Ask and ye shall receive (in powershell form):
$fName = "last.exe"
$fContent = get-content $fName
$fContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fContent)
$fContentEncoded = [System.Convert]::ToBase64String($fContentBytes)
$fContentEncoded set-content ($fName + ".text")
Now you can at least say that all your .exes live in base64-encoded .texts.
- billforsternz 13y agoThanks, upvoted. (But, also, note that I wasn't really hoping this was an article about how to store my Windows .exes as text :-)
- ygra 13y agoI guess that should rather be Get-PSDrive -PSProvider Filesystem | Get-ChildItem -Recurse -Path { $_.Root } -Filter *.exe | ForEach-Object { $bytes = Get-Content $_ -Encoding Byte -ReadCount 0 $text = [Convert]::ToBase64String($bytes) $text | Set-Content ($_.FullName + '.text') } Reading the files as UTF-8 and converting them back into a byte array isn't such a great idea, I think ;-)