I'm trying to write a Windows Powershell script but when I write $ curl wttr.in
for example, I get the expected output however, when I do $a=curl wttr.in;echo $a
I just get gibberish. I'm using the curl executable located in C:\Windows\System32\
since I removed the default Powershell aliases related with Invoke-WebRequest
(curl
and wget
). Is there something I'm doing wrong?
Here is what I mean:
Asked
Active
Viewed 333 times
3

136
- 1,083
- 1
- 7
- 14
-
I don't get either option unless I look at the `.Content` property of the curl result. – Joel Coehoorn Mar 10 '21 at 21:25
-
1Also, upvote for showing me `wttr.in` – Joel Coehoorn Mar 10 '21 at 21:26
-
@JoelCoehoorn are you sure you're using the curl executable located in `System32`? It seems you may be using Powershell's `Invoke-WebRequest`. Try doing `Get-Alias curl` and see if this is true. – 136 Mar 10 '21 at 21:28
2 Answers
1
I believe it has to do with encoding. A workaround would be simply add Out-String
when capturing
$a = C:\Windows\system32\curl.exe wttr.in | Out-String
$a

Doug Maurer
- 8,090
- 3
- 12
- 13
1
I could not test it (response was "no more querys"), but you can force the output encoding into a specific encoding Encode a string in UTF-8 may take some testing to find the right output.

Paul Fijma
- 467
- 4
- 9