elgrego
elgrego

Reputation: 372

powershell character encoding from System.Net.WebClient

I am running the following command:

([xml](new-object net.webclient).DownloadString(
"http://blogs.msdn.com/powershell/rss.aspx"
)).rss.channel.item | format-table title,link

The output for one of the RSS items contains this weird text:

You Don’t Have to Be An Administrator to Run Remote PowerShell Commands

So, the question is:

Upvotes: 5

Views: 6936

Answers (1)

Filburt
Filburt

Reputation: 18061

You need to set the encoding property of the webclient:

$wc = New-Object System.Net.WebClient
$wc.Encoding = [System.Text.Encoding]::UTF8
([xml]$wc.DownloadString( "http://blogs.msdn.com/powershell/rss.aspx" )).rss.channel.item | format-table title,link

Upvotes: 11

Related Questions