I need to get the original byte-sequence from a given unicode-string via Powershell.
I made multiple test, but its not that easy as I thought.
Here a sample that is failing:
$bytes = [byte[]]@(239,174,61,217,221,117,215,174,248,221,253)
$string = [System.Text.Encoding]::Unicode.GetString($bytes)
# here i need a solution to get back $bytes from the unicode-string:
$bytes2 = [System.Text.Encoding]::Unicode.GetBytes($string)
# compare result:
cls
[string]::Join(',', $bytes)
[string]::Join(',', $bytes2)
What is wrong here? I need a solution that gets me the original bytes here.