RSS2Twitter PowerShell script

As you might have noticed I’ve been using Twitter quite often lately. On my previous weblog I installed a Drupal Twitter module for updating Twitter with my latest blog posts. But now I migrated to Technet Blogs I didn’t had this possibility anymore, so I looked for an easy way to have my latest blog posts updated to Twitter.

I searched for “rss2twitter” on Windows Live Search and found a perl script but that didn’t work for me. It just failed with the next errors:

Malformed UTF-8 character (1 byte, need 4, after start byte 0xf1) at C:\Temp\rss
2twitter\rss2twitter.exe line 128.”

So I though why not use PowerShell? With the help of Out-Twitter from Doug Finke it was quite easy.

So here is the PowerShell RSS2Twitter script:

# Rss2Twitter PowerShell Script
# Stefan Stranger 2008
# Retrieve last post from RSS feed and post to Twitter Account
# Out-Twitter function from Doug Finke (

function Send-TwitterStatus($status)
# Enter Twitter Username and Password
$userName = "twitteraccount"
$password = "password"

$url = ""
$data = "status={0}" -f $status

$request = [Net.WebRequest]::Create($url)
$request.Credentials = New-Object System.Net.NetworkCredential($userName, $password);
$request.ContentType = "application/x-www-form-urlencoded";
$request.Method = "POST";

$bytes = [System.Text.Encoding]::UTF8.GetBytes($data)

$request.ContentLength = $bytes.Length

$requestStream = [System.IO.Stream]$request.GetRequestStream()
$requestStream.write($bytes, 0, $bytes.Length)

$response = $request.GetResponse()
$reader = [System.IO.StreamReader]$response.GetResponseStream()


#Enter rss feed from where you want update Twitter
$wc = New-Object Net.WebClient
$rss = [xml]$wc.DownloadString($uri)
$posts = $ | Select-Object title, link
#Retrieve last post on RSS feed page.
$lastpost = $posts[0].title + ' ' + $posts[0].link

#Post to Twitter
Send-TwitterStatus $lastpost


Comments (1)

  1. Anonymous says:

    I just got a Tweet from jpavleck ( and he pointed me to Why didn’t I find this earlier 😉

    Maybe gonna use this for the MPNotifier Twitter account…

Skip to main content