Every year I like to watch the complete last series of 24 with Kiefer Sutherland as Jack Bauer working for CTU. Since the first series I have watched the use of technology in the show and been asked on many occasions – “Can they really do that?” I have a lot to thank the show for since it gives an interesting if stretched perspective on technology and its role in business and society but more mundanely I smile every time I hear the bits about opening sockets.
I was introduced to sockets and streams programming a long time back when I worked for a government department which also had a three letter acronym but it wasn’t CTU. It related to reverse terminal server printing using DEC LAT protocols over X.25 – the description is a lot more interesting than the reality of the code that was developed and the problem it solved. Apart from the long distance chats with the Icelandic X.25 card developers – which was fun to say the least due to language and dialect difficulties.
So as part of researching Microsoft Powershell and its communications capabilities I found the socket and port handling of specific interest. I really should mention the site that I found some very interesting info on turns out to be the Powershell Cookbook author Lee Holmes at his blog web site and I’ve added him on this sites blog roll since I’m sure there will be plenty more references.
A simple code example would be ( replace the xxx with the ip address of the web site )
$page = (new-object System.Net.WebClient).DownloadString(“http://xxx.xxx.xxx.xxx:80”)
$page
or if site not on a default port
$page = (new-object System.Net.WebClient).DownloadString(“http://xxx.xxx.xxx.xxx:9999”)
$page
The potential uses of Windows Powershell communications code would include
– data extraction from web pages
– xml data “transfer”
– pop and smtp email
– socket level communication between applications.