Cool stuff you can do with PowerShell

PowerShell was designed to help systems administrators to perform administrative tasks in a quicker and automated way, however it is also useful for doing fun stuff. Let me show you a few examples after the break.

One of the cool features in PowerShell is the ability to create COM objects and run its methods. I don’t want to sound like I don’t want to let go of the past, but there is a really cool COM object available in Windows called “SAPI.SPVoice”. You may ask: Witch cmdlet can I use to create COM objects in PowerShell? Well, there is a pretty good chance that you’ve already guessed it by now. You are right. It is the New-Object cmdlet. You just have to add “-COMObject” parameter and pass object name as a value. So turn on your speakers and try running this two lines:

$s = New-Object -ComObject SAPI.SPVoice
$s.Speak("I'm a COM object and I can speak!")

Cool, isn’t it. Another cool fact about PowerShell is that it is build on top of and integrated with .NET. That means that everything that is possible to do with .NET it is also possible to do with PowerShell. We can create .NET object easily with the New-Object cmdlet. The only difference to COM is that, for .NET objects we add “-Type” parameter instead of “-COMObject”. Below examples uses New-Object cmdlet to create an object of class “System.Net.WebClient” which allows us to download a file or web page from the internet. Try running it. Again, don’t forget to turn on your speakers.

$webClient = New-Object -TypeName "System.Net.WebClient"

$s = New-Object -ComObject "SAPI.SPVoice"
$s.Rate = -1;

$url = ""
$x = [XML]$webClient.DownloadString($url)

$x.feed.entry | foreach {
    $s.Speak("Tweet from: " + $

Isn’t it cool that PowerShell can tell you what people are talking about it on Twitter? That is it for today. I wish you successful PowerShell-ing. :)

2 thoughts on “Cool stuff you can do with PowerShell

Leave a Reply