PowerShell script to set Skype status text to latest blog or twitter update

In my current company (Jelastic) we have something happening to us all the time: latest blog posts, awards, media mentions, etc. We are doing a decent job pushing these to various social media, but I also wanted to get these to my contacts in Skype (Skype gives you the ability to set your status text in your profile).

Below is the PowerShell v3 script that I wrote today to do that! :)

It takes the latest item from my blog and twitter feed, sees which of them is fresher, and (unless the tweet is just my reply to someone) pushes that to Skype (the property is called MoodText).

Here’s the script:

###################################################
# Set-SkypeStatusText.ps1
# Gets latest post from RSS feed (e.g. blog) and Twitter
# Picks whichever is the latest and sets it as status text (MoodText) in Skype
# (unless the latest tweet is a reply)
#
# NOTE: On x64 boxes, use PowerShell x86 (for Skype compat)
#
##################################################
# (c) 2012 - Dmitry Sotnikov
##################################################

# Customize these for yourself
$myblog = "http://blog.jelastic.com/feed/"
$myTwitterHandle = "DSotnikov"

# Get the blog feed
$blogFeed = Invoke-RestMethod $myblog

# Get the twitter feed
$twitterFeed = Invoke-RestMethod `
"https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=$myTwitterHandle"


# If twitter is more recent and not a reply (does not start with @) use it
if (($twitterFeed[0].pubDate -gt $blogFeed[0].pubDate) -and
($twitterFeed[0].description[$myTwitterHandle.Length+2] -ne "@")){
$latestPost = $twitterFeed[0].description.Substring($myTwitterHandle.Length+2)
} else {
$latestPost = "$($blogFeed.Item(0).title): $($blogFeed.Item(0).link)"
}

# Set the status in twitter
$skype = New-Object -ComObject Skype4Com.Skype
$skype.CurrentUserProfile.MoodText = $latestPost

Now if you want to have this happen automatically you can just schedule it using Windows Task Scheduler.

Important:

  • Make sure that you use 32-bit (x86) version of PowerShell if you are on 64-bit Windows – otherwise Skype object will not get found (so the filepath for the Windows task on x64 Windows will likely be %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe)
  • Either sign your script or set ExecutionPolicy to RemoteSigned – otherwise the script execution will fail.
About these ads

5 Responses to “PowerShell script to set Skype status text to latest blog or twitter update”


  1. 1 cavallogolooso November 11, 2012 at 7:52 pm

    Reblogged this on Depresso Gioioso.

  2. 2 Stefan Stranger November 12, 2012 at 10:59 am

    Hi Dmitry,

    Great post, but to get it working I needed to do some datetime parsing.

    This is what I needed to change to get it working for my twitter and blogfeeds datetime formatting.

    # If twitter is more recent and not a reply (does not start with @) use it
    if (([DateTime]::ParseExact($twitterFeed[0].pubDate, “ddd, dd MMM yyyy HH:mm:ss +0000″, $Null) -gt $blogFeed[0].pubDate) -and
    ($twitterFeed[0].description[$myTwitterHandle.Length+2] -ne “@”)){
    $latestPost = $twitterFeed[0].description.Substring($myTwitterHandle.Length+2)
    } else {
    $latestPost = “$($blogFeed.Item(0).title): $($blogFeed.Item(0).link)”
    }

    /Stefan

  3. 4 Daniel Rapp February 26, 2013 at 4:55 pm

    This is really cool, after a long day messing with it i finally understood the logic and got it working :)
    (i failed to read the last bit that 32 bit ps was needed)

  4. 5 Admirador de damas January 8, 2014 at 3:01 pm

    Great.

    Works for new Skype-MSN version ? (now, in january 2014)

    which are requeriments for executing scripting ? Skype installed and Powershell 2.0 or later ? any Skype assembly in .net ?

    which is your twitter alias ? :-)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




My Recent Tweets

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

November 2012
M T W T F S S
« Aug   Feb »
 1234
567891011
12131415161718
19202122232425
2627282930  

Follow

Get every new post delivered to your Inbox.

Join 93 other followers

%d bloggers like this: