Project Description
A simple helper library and scripts that work with agsXMPP to allow you to send and receive messages via Jabber.

agsXmpp is a GPL .Net Xmpp library that is a project of AG Software -- they in no way are affiliated with PoshXmpp.

Here's a simple example ... don't forget you have to put both DLLs in the same place, and use InstallUtil PoshXmpp.dll and Add-PsSnapin PoshXmpp to get PoshXmpp loaded and ready
$jaykul = "Jaykul@im.Flosoft.biz"

# you'll be prompted ... and you'll have to enter a jabber login & password
# you could also pass in an HTTP polling server here, like: http://im.flosoft.biz:5280/http-poll/ 
PoshXmpp\New-Client (Get-Credential)
PoshXmpp\Send-Message $jaykul "Hi there Joel!"

# You'll be sitting, waiting for messages ... press any key to continue
PoshXmpp\Receive-Message -Loop

# This will make sure you're logged off ...
$PoshXmppClient.Close()


The $PoshXmppClient object is created by the New-Client cmdlet, which also returns it, so you can store it in a different variable in case you want to log into multiple servers. You can pass the -Client parameter to any of the commands, or they will use the default $PoshXmppClient client. If it becomes disconnected, you'll get an error, and can safely re-run New-Client.

Try this one, to listen to IRC (you need Out-Voice)

param (
    $JabberId = $( Read-Host "Bot's Jabber ID" )
   ,$Password = $( Read-Host "Bot's Password" -asSecure)
   ,$Chat[] = @("PowerShell%irc.FreeNode.net@irc.im.flosoft.biz") # Some IRC channels to join!
   ,$ChatNick = $("PowerBot$((new-object Random).Next(0,9999))")  # Your nickname in IRC
)

$global:PoshXmppClient = 
PoshXmpp\New-Client $JabberId $Password # http://im.flosoft.biz:5280/http-poll/
foreach($room in $Chat) {
   PoshXmpp\Connect-Chat $room $ChatNick
}

"PRESS ANY KEY TO STOP"
while(!$Host.UI.RawUI.KeyAvailable) {
   PoshXmpp\Receive-Message -All | foreach-object {
      "{0}-{1} said: {2}" -f ($_.From.User -split "%")[0], $_.From.Resource, $_.Body | Out-Voice -Wait -Pass
   }   
   [Threading.Thread]::Sleep( 100 )
}

PoshXmpp\Disconnect-Chat $Chat $ChatNick
$global:PoshXmppClient.Close();

Other cmdlets so far


Note that all of these cmdlets actually use methods exposed on the XmppClient object that the New-Client creates, or on it's members (particularly on the MessageManager, ContactManager, and ChatManager members). You can do even more than this using PowerShell script with those objects ...