title: How to post a tweet to twitter using Powershell?
body: <p>Has anyone used the following code? How do I make it post a tweet? I know I have to use the "<code>$req.Context.RawUri = [Uri]'http://api.twitter.com/version/statuses/update.xml</code>" but I can't get the "<code>$res = [xml][DevDefined.OAuth.Consumer.ConsumerRequestExtensions]::ReadBody($req)</code>" right.</p>
  
  <pre><code>Add-Type -Path C:\OAuthDevDefined\DevDefined.OAuth.dll
  
  $cons = New-Object devdefined.oauth.consumer.oauthconsumercontext
  
  $cons.ConsumerKey = 'key'
  
  $cons.ConsumerSecret = 'key'
  
  $cons.SignatureMethod = [devdefined.oauth.framework.signaturemethod]::HmacSha1
  
  $session = new-object DevDefined.OAuth.Consumer.OAuthSession $cons, $null, $null, $null
  
  $accessToken = new-object DevDefined.OAuth.Framework.TokenBase
  
  $at = import-cliXml C:\temp\myTwitterAccessToken.clixml
  
  $accessToken.ConsumerKey, $accessToken.Realm, $accessToken.Token, $accessToken.TokenSecret = `
    $at.ConsumerKey, $at.Realm, $at.Token, $at.TokenSecret
  
  $req = $session.Request($accessToken)
  
  $req.Context.RequestMethod = 'GET'
  
  $req.Context.RawUri = [Uri]'http://api.twitter.com/1/statuses/friends_timeline.xml?count=5'
  
  $res = [xml][DevDefined.OAuth.Consumer.ConsumerRequestExtensions]::ReadBody($req)
  
  $res.statuses.status | % { $_.user.Name }
  </code></pre>