Prof. Powershell

Return of PSCX

Extensions built by the PowerShell community, for the community, has gone much improvement. Here's a few of my favorite extensions.

In the past I've discussed the free PowerShell Community Extensions project. The community extensions are a collection of cmdlets and scripts developed by members of the PowerShell community. The goal is to extend PowerShell's functionality to meet needs that aren't provided out of the box from Microsoft. I'm happy to say that version 2 of the PowerShell Community Extensions (PSCX) is now available for download from CodePlex.

PSCX has undergone a significant overhaul and now requires PowerShell 2.0. The primary reason for this change is that PSCX 2.0 is delivered as a module and not as a PSSnapin, as was the case with 1.0. Modules are much more flexible and easier to deploy since all you need to do is copy files -- there's no installation or setup.

PSCX 2.0 ships with 87 cmdlets, 34 functions and a few other goodies such as an Active Directory PSDrive provider. To get all of this goodness you first need to import the module:

PS C:\> import-module psxc

Use Get-Command to see what's inside:

PS C:\> get-command -module psxc

Most of the cmdlets have complete help and examples. You'll also want to look through the about file:

PS C:\> help about_pscx

Because I write a lot about PowerShell, I end up copying and pasting. The Out-Clipboard cmdlet is a lifesaver. Suppose I want to copy the output of this command:

PS C:\> dir feed: | where {$_.itemCount -gt 0}

All I need to do is pipe it to Out-Clipboard:

PS C:\> dir feed: | where {$_.itemCount -gt 0} | Out-Clipboard

By the way, the feed: PSDrive also comes from PSCX and exposes the Internet Explorer RSS feed store as a drive.

Another new tool I like is Show-Tree. This is similar to the tree command in the CMD.EXE shell, except this works with non-filesystem PSDrives as well. The output is best displayed in a screen shot (see Fig. 1).

Show-Tree goes deep
Figure 1. Show-Tree displays -- what else? -- a tree view similar to what you get with the tree command via CMD.EXE. (Click image to view larger version.)

You can also have Show-Tree display properties and control how "deep" to go (see Fig. 2).

Show-Tree goes deep
Figure 2. Show-Tree's roots can run deep. (Click image to view larger version.)

Finally, (I could go on all day), I like the Get-DriveInfo cmdlet (see Fig. 3).

Get-Driveinfo cmdlet
Figure 3. What you see is drive info via the Get-Driveinfo cmdlet. (Click image to view larger version.)

I wish the cmdlet supported connecting to remote computers. But you could install the PSCX modules you need on your servers and then use PowerShell remoting to connect to them, load the module, and run the command.

Think of the PowerShell Community Extensions as a PowerShell resource kit. You may not need all the functionality every day, but when you do, you'll be glad it is in your toolbox.

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 Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular