5

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:

  • Why the mix up in characters? What happened to the apostrophe? Why is the output rendered as Don’t when it should just render as Don't?
  • How would I get the correct character in the PowerShell standard output?
1
  • this shows an important aspect of powershell .Net interaction. I usually program in .Net and failed to view this as a .Net setting to be made. Commented Jan 9, 2010 at 7:26

1 Answer 1

11

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.