Prof. Powershell

For PowerShell Help, It Takes a Community

If you ever need help with PowerShell, you only need to turn to other PowerShell fans. And some of them are creating free or nearly-free tools, ready to download and use.

One of the best reasons for adopting PowerShell is the community. Besides the number of online resources for getting help, there are also many people creating PowerShell-based tools. Often, these tools are free and fill feature gaps or make PowerShell easier to use. Here a few you may want to consider trying out.

PowerShell Community Extensions
The PowerShell Community Extensions have been around for quite awhile and I've written about them before. The latest version, currently in beta, is designed to work with PowerShell 3. One of my favorite changes is that this is now packaged as a module. This means that all you need to do is extract the zip file to your Modules subfolder.

Actually, there is one more change you might have to make: It is very likely the files will be blocked as having come from the Internet. This means that with an execution policy of remote signed, you'll get error messages when you import the module. You need to go into the properties of the files and click Unblock. Or if you are running PowerShell 3, you can use the new Unblock-File cmdlet:

PS C:\> dir (Join-Path $env:psmodulepath.split(";")[0] PSCX) -recurse | Unblock-File

This assumes your user path is first and you installed the module in this location. But now it can be imported:

PS C:\> import-module pscx

As of this writing this is still in beta so don't be surprised be an error or two. But what do you get? All sorts of goodies:

PS C:\> get-command -module pscx

Try these nuggets:

PS C:\> "Hello $env:username. PowerShell Community Extensions rock!" | Out-Speech

PS C:\> get-privilege

PS C:\> get-loremipsum -Length 3 -Language Spanish | out-file c:\work\testfile.txt

Help and examples aren't as complete as they could be, but most of the commands aren't too difficult to figure out. You can download the extensions from http://pscx.codeplex.com/.

ShowUI
When it comes to creating graphical PowerShell scripts, you can either use WinForms or Windows Presentation Foundation. Using WPF can be very tedious in a PowerShell script. The ShowUI module is a library of PowerShell commands that facilitate creating graphical, WPF-style PowerShell scripts. Like the PSCX module, you may need to unblock files:

PS C:\> dir (Join-Path $env:psmodulepath.split(";")[0] ShowUI) -recurse | Unblock-File

Using the commands can be done interactively, although you are more likely to use a script. I'll warn you that there is still a lot of programming-type scripting required so don't expect to be proficient from the very beginning.

Eventually you can create a script like this:

Import-Module ShowUI
$getEventInput = StackPanel -ControlName 'Event Logs Since' {
  New-Label -VisualStyle 'MediumText' "Log Name"
  New-ComboBox -IsEditable:$false -SelectedIndex 0 -Name LogName @("Application", "Security", "System")
  New-Label -VisualStyle 'MediumText' "Get Event Logs Since..."
  Select-Date -Name After
  New-Button "Get Events" -On_Click {
  Get-ParentControl | Set-UIValue -passThru | Close-Control
  }
} -show

$getEventInput.remove("togglebutton")
Get-EventLog @getEventInput

When executed, it should provide a graphical result like Fig. 1.

ShowUI

Figure 1. Nifty, yes?

Learn more and download the module from http://showui.codeplex.com/.

PowerShell Proxy Extensions
One of PowerShell's more advanced features is the ability to create proxy functions. These are customized commands where you add parameters that you think would be helpful, or remove parameters to create a more "locked down" version of a command. Without getting into the arcane details, trust me when I say it is complicated. Fortunately, the PowerShell Proxy Extensions, also delivered as a module, makes this a much easier proposition.

Download the module from http://pspx.codeplex.com/ in either msi or zip format and load the module in your home folder. The module itself only has two functions, Get-ProxyFunction and New-ProxyFunction. But the module folder includes a number of demo scripts which you can use as is or as learning material. Documentation is currently sparse and this is definitely not for the beginner. But if you have enough experience to tackle proxy functions I think you'll get by and find this very helpful.

There are many, many other PowerShell projects out there. If you have something you think I should pay attention to or would like to know more about, please let me know.

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

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025