Prof. Powershell

It Takes a Community

The PowerShell Community Extensions comes with a bevy of scripts and cmdlets that'll give you a leg up on automating your work.

Even though PowerShell 1.0 is not very old, it already has a rich and growing ecosystem. A prime example is in the PowerShell Community Extensions, an open source project headed up by PowerShell MVP Keith Hill that includes many scripts, functions, cmdlets and more to help you get even more out of PowerShell. Think of it as the "PowerShell Resource Kit." The version I have as of this writing is but Keith has been promising a new release which may be out by the time you read this. You can download the Community Extensions from After the install, make sure you have the PSCX PSSnapin loaded into your PowerShell session. You might need to add this:

Add-pssnapin PSCX

to your PowerShell profile. There's way too much to cover. Run this command at a PowerShell prompt to see all the available cmdlets:

PS C:\> get-command -pssnapin pscx

I do want to point out three cmdlets that I find helpful or that I think you will enjoy.

Out-Clipboard -- I use this quite a bit. It is designed to take pipeline input and send it to the Windows clipboard:

PS C:\> ps | out-clipboard

With this command I've sent the results of the Get-Process cmdlet (I'm using the PS alias) to the Windows clipboard. I can paste this anywhere I want. I also use this for my signature block. I have a text file that I sometimes want to insert into forum or newsgroups posts. I've created my own function to get the content of my signature file and pipe it to Out-Clipboard:

PS C:\> (dir function:\get-mysig).definition
Get-Content $sig | out-clipboard

Whenever I need my signature block, I jump to my (always open) PowerShell session , run Get-Mysig and paste.

Send-SMTPMail -- Wouldn't it be great to send mail directly from PowerShell?

PS C:\> Send-SmtpMail -SmtpHost -To "[email protected]" `
>> -From "[email protected]" -Subject "PowerShell Rocks" `
>> -Body @"
>> PowerShell is wicked cool and lets me get a lot done.
>> Jeff"
>> "@

The cmdlet supports html bodies, sending attachments and authentication. Check the cmdlet help for more detailed information. If you use it internally you might need to configure our mail servers to allow relaying.

Write-Zip -- Finally, wouldn't it be nice to create a zip file from the console?

PS C:\> write-zip (dir c:\scripts\*.ps1 -recurse ) c:\ -level 9

Mode        LastWriteTime  Length  Name
----        -------------  ------  ----
-a---  4/26/2008  2:17 PM  11628

The Write-Zip cmdlet will add all my ps1 files to the archive. The cmdlet includes a parameter to delete the original. Combine this with the Send-SMTPMail cmdlet and its ability to send attachments and now you're really automating!

As I said earlier, the PowerShell Community Extensions should be a part of your PowerShell experience. Don't forget to look at the scripts and functions as well.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular