header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left
Dec 5

Written by: SAPIENScripter
12/5/2007 9:00 AM

Yesterday I wrote about using PowerShell and the COM object for Windows Live Messenger. Well, in addition to my own status, what about my contacts? Wouldn't it be nice to see who is online or what their status is?  Easy enough.

The messenger object has a property called mycontacts.

$messenger=New-Object -com "Messenger.UIAutomation"
$messenger.mycontacts

That's nice. But I want to leverage PowerShell to make it more meaningful. For example, show me only users are are not offline:

$messenger.mycontacts | Where {$_.status -ne $MISTATUS_OFFLINE}

That's pretty nice.  But until I memorize the status codes, I might need a little help in decoding.  So I threw a quick function together:

Function Decode-MessengerStatus {
    Param([int]$status=0)

Switch ($status) {
    $MISTATUS_UNKNOWN {Return "Unknown"}
    $MISTATUS_OFFLINE {Return "Offline"}
    $MISTATUS_ONLINE {Return "Online"}
    $MISTATUS_INVISIBLE {Return "Invisible"}
    $MISTATUS_BUSY {Return "Busy"} 
    $MISTATUS_BE_RIGHT_BACK {Return "Busy/BRB"}
    $MISTATUS_IDLE {Return "Idle"}
    $MISTATUS_AWAY {Return "Away"}
    $MISTATUS_ON_THE_PHONE {Return "On the phone"}
    $MISTATUS_OUT_TO_LUNCH {Return "Out to lunch"}
    
    Default {Return "Undefined"}
  }

}

Now I can use an expression like this:

$messenger.mycontacts | Where {$_.status -ne $MISTATUS_OFFLINE} | `
select FriendlyName,SignInName,@{Name="Status";Expression={Decode-MessengerStatus $_.Status}}

I put this into a function so I can use an expression like this:

get-onlinecontacts | sort status

I've attached an updated copy of all my functions.

By the way, starting an IM chat with someone from the console couldn't be easier. Use your contacts signing name:

$messenger.instantmessage("myfriend@somewhere.com")

The GUI chat window will popup and you can begin sending your message.  Now that I can manage Live Messenger from PowerShell, I just might use it more often!

manage-messenger.txt

Tags:
 

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Blogs
  
Search Blogs
  
Archives
  
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer