Previous month:
April 2009
Next month:
August 2009

May 2009

Skype Automation in Powershell : Don’t have to dial in conference codes anymore

For teams located in different locations conference calling is a must. Most of these calling facilities have toll free 1-800 dial in numbers. Skype lets you dial in to the toll free 1-800 numbers without any cost. One annoying thing with these conference calls is that you have to dial in a pin code to enter. If you are dialing in to one conference only then you memorize it. But if you have to dial in several different conferences calls in a day it becomes a pain. You would probably have to lookup the outlook calendar entry and type it in, which is quite annoying and distracting. Recently I have been trying to do everything with Powershell. As you have guessed … … now we can dial into a Skype meeting with one powershell command.

You can download the powershell script : Download skype.ps1 (5.2K)

I just wrote a function ( just bare minimum, no error handling ) that calls a Skype contact or a phone number waits for certain time then enters the pin as DTMF codes. I have the different meeting and number to different  functions which calls this function. And now I can get into any meeting without hassle.

The function is called Call-SkypeContactSendDTMF. The first parameter can be a skype contact name or a saved phone only contact or a number to dial. The second parameter is the number of seconds to wait after the phone has been picked up by the conference bot. The third parameter is the DTMF codes. You can add pause by putting in “@” to pause for a second. Here is the calling syntax

Call-SkypeContactSendDTMF (ConferenceNo, SecondsTOWait, DTMFCodes)

So I have created different entries from the meetings like this

function call-conf1()
   Call-SkypeContactSendDTMF ("ConfNo",10,"7363784394#")

All I have to do is type in call-conf1 like this


I love powershell. Hope this helps someone.

btw: When executing this script remember that we want the function to stay in memory so you can either put this in the powershell profile or you can call it in the same context by adding a “. ” to it.

Executing Powershell Scripts in the Same Execution Context

Recently I have been trying to do almost everything in Powershell. With the release of Powershell V2 RC and the awesome visual debugger that comes with Powershell called Powershell ISE, I have a Powershell window open at all times. I am getting my google calendar events form command line, doing recursive ftp uploads and download as well. Now I have started to even do outlook automation with PS.

The Problem

Any slightly efficient developer would write functions and reuse them later. So I tended to write functions add kept on adding them to my Powershell profile file. After a while that turned a little messy and hard to manage. So now I thought why don’t write different script files put my functions in there and use them when needed. So I created functions for Google Data API, Outlook functions. Now when I call them from the prompt, after execution of the script the functions are no longer there. It is because the scriptblock runs in a different execution context and after execution the context is removed. So the functions I have put the file no longer exist when I call them.

For example I have written a function in myfunc.ps1 to convert string into base64 string which looks like this

function tobase64 ( $asciistring )
  return [Convert]::ToBase64String([System.Text.Encoding]

Now after running the script .\myfunc.ps1 when I call the function, it no longer works.


After running around the internet for hours, looking for a solution to run scripts in the same executions context and trying out several different approaches, I was about to give up. Then I found the worlds easiest solution in Donn Felkers blog. All you need to do is to add a simple dot ( “.” ) at the start of the line to make it run the in the same context.

So if you were running the script like this,


You should run it like this

. .\myfunc.ps1 
. ‘c:\somefolder\myfunc.ps1’

See the added dot? That does the trick. I wish this was advertized more, then I wouldn’t have had to search for hours to find a solution.

kick it on