I have a powershell script which pulls out data from an API using the below command
Invoke-RestMethod -Method Post -Uri $WebServiceURL -Body $json -ContentType "Application/json"
The data present in the API server end contains an Em Dash "–".
When I pull the data using Postman, it displays the Em Dash as it is, but the moment i pull the data using Powershell and print the output, it displays some weird characters as below.
OUPath=ABCD.COM/Test/All Users/India/Test/TestâOU/Desktop Users
Em Dash is printed as "â".
I tried converting the Output Encoding of Powershell using below command, but no luck.
[Console]::OutputEncoding = [Text.Encoding]::Utf8
Current Powershell Version Details.
PS Codes> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Default Output Encoding as below :
PS Codes> [Console]::OutputEncoding
IsSingleByte : True
BodyName : IBM437
EncodingName : OEM United States
HeaderName : IBM437
WebName : IBM437
WindowsCodePage : 1252
IsBrowserDisplay : False
IsBrowserSave : False
IsMailNewsDisplay : False
IsMailNewsSave : False
EncoderFallback : System.Text.InternalEncoderBestFitFallback
DecoderFallback : System.Text.InternalDecoderBestFitFallback
IsReadOnly : True
CodePage : 437