I want to convert cmdlets to windows-1251 encoding so that Russian characters are displayed on the output.
My code:
$result = 'Invoke-RestMethod -Method "Post" -Uri https://ntfy.sh/most -Body "Hello 123 Привет" -UseBasicParsing'
$rus_result = [System.Text.Encoding]::GetEncoding('windows-1251').GetString([Byte[]]$result)
PowerShell Errors:
InvalidArgument: Cannot convert value "Invoke-RestMethod -Method >"Post" -Uri https://ntfy.sh/most -Body "Hello 123 Привет" ->UseBasicParsing" to type "System.Byte[]". Error: "Cannot convert value >"Invoke-RestMethod -Method "Post" -Uri https://ntfy.sh/most -Body >"Hello 123 Привет" -UseBasicParsing" to type "System.Byte". Error: >"Input string was not in a correct format.""