Script Editors

Admittedly, the Scripting Guys might not be the best people to talk about script editors; after all, we still rely on good old Notepad when it comes time to write a script. However, after surveying some of the editors available for Windows PowerShell, well, we just might turn good old Notepad out to pasture.

On This Page

Sapien PrimalScript
PowerShell Analyzer
PowerShell Plus
PowerGUI

Sapien PrimalScript

For example, take Sapien Technologies’ PrimalScript (Sapien Technologies; $179 for the Standard edition, $399 for the Enterprise edition), long the top-selling script editor for system administration scripters. (And not just system administration scripters who use Windows PowerShell. The latest version of PrimalScript, PrimalScript 2007, supports over 30 different scripting languages, including KixTart, Perl, Python, Ruby, and – dare we say it? – VBScript.)

That’s impressive, but what exactly can PrimalScript do? Well, to tell you the truth, a much easier question to answer would be this: what can’t PrimalScript do?

Wait, we take that back: that’s not an easier question to answer, mainly because we haven’t been able to find anything that PrimalScript can’t do. Needless to say, PrimalScript includes all the usual features you’d expect to see in a world-class script editor: line numbering; color-coding; IntelliSense; script debugging and signing; even a spelling checker and a search-and-replace function. The detailed interface should give you a hint as to the vast number of capabilities built into the program:

PrimalScript

But that’s only the beginning. PrimalScript ships with a number of tools that make your life easier, ranging from the WMI Explorer (still the best way we’ve seen to ferret out information about the WMI classes on your computer) to the Script Packager, a nifty little utility that enables you to package your PowerShell scripts as standalone executable files. (Is that cool? You bet it is: imagine being able to share an executable file, which can’t be easily modified, rather than a script file, which can be easily modified.)

In addition to these big-ticket items, PrimalScript includes a whole host of little things that make your scripting life easier. For example, suppose you need to convert a number to its hexadecimal equivalent. That’s fine: just type the number into the script editor, select the value, then go to the Ed it menu, click Convert, then choose Hexadecimal. It’s like magic, except for one thing: unlike magic, it actually works.

You can do the same sort of thing with PowerShell aliases. Suppose you have a PowerShell script that includes a bunch of aliases like gci. Would you rather have the cmdlet name (Get-ChildItem) spelled out for you? Then just highlight gci, go to the Ed it menu, click Convert, then choose Alias to cmdlet.

The truth is, PrimalScript makes scripting so easy it’s almost unfair to use it.

Uh, notice that we said almost unfair. As we all know, all’s fair in love and scripting. And scripting, at least, comes with an editor that can make things much easier.

PowerShell Analyzer

Wait, don’t go: we’ve only just begun to scratch the surface when it comes to PowerShell script editors. For example, we haven’t mentioned PowerShell Analyzer from Shell Tools ($129; 45-day free trial download). PowerShell Analyzer is more than just a script editor (although it is a very nice script editor). Instead, PowerShell Analyzer is as much an interactive environment for running scripts as it is a development environment for writing scripts. What does that mean? Well, here’s an example: built right into the product is a “provider” explorer that enables you to get information about the PowerShell providers installed on your system. But this explorer doesn’t just give you some generic information about these providers; instead, PowerShell Analyzer allows you to drill down into, and use, those providers. For example, take a look at the information that gets returned when you click on the Env provider:

PowerShell Analyzer

Here’s another cool feature of PowerShell Analyzer. As you probably know, if you type Get-ChildItem C:\Scripts in the PowerShell console you get back basic information about the files and folders found in C:\Scripts:

Directory: Microsoft.PowerShell.Core\FileSystem::C:\scripts


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        10/22/2007   2:13 PM            ps
d----        10/30/2007   8:38 AM            Test
-a---          1/3/2007   8:00 AM     333432 6of12.txt
-a---         12/7/2007  10:26 AM        474 ad.ps1
-a---          1/3/2007   8:00 AM        540 alice.zip
-ar--          1/3/2007   8:00 AM        155 Audits.xml

That’s cool. But, without you having to write any additional code, look at the kind of information PowerShell Analyzer provides you:

PowerShell Analyzer

In other words, with PowerShell Analyzer you can get more – and more detailed – information about each file in the folder. (To get information about another file, just select the file name from the dropdown list.) Why did we say that PowerShell Analyzer is as much an interactive environment for running scripts as it is a development environment for writing scripts? Well, now you know.

What’s that? Why are some of the properties in the screenshot shown in boldface? That’s easy: those are read-write properties. Simply knowing which properties are read-write is definitely handy, but here’s something even handier: PowerShell Analyzer allows you to change those read-write properties simply by clicking the property value and selecting an option from the dropdown list. Want to make the file Alice.zip into a read-only file? Then click the current value (False) and select True from the dropdown list.

Try doing that with your typical script editor.

Oh, and we can’t go without showing you how PowerShell Analyzer reformats PowerShell’s help files, making these files a little more, well, helpful:

PowerShell Analyzer

Nice. Say, could you do us a favor? When you go to get your copy of PowerShell Analyzer (as you no doubt will), could you pick up a copy or two for the Scripting Guys? Thanks!

PowerShell Plus

PowerShell Plus (free for non-commercial use) is another product from Shell Tools; in fact, if you purchase PowerShell Analyzer you get a copy if PowerShell Plus thrown in for free. (But don’t worry; as you’re about to see, the two tools complement rather than overlap one another.) To put it bluntly, PowerShell Plus is amazingly jam-packed with features, especially for a product that doesn’t cost anything. For example, PowerShell Plus comes with a script editor, a full-blown editor that includes line numbering; IntelliSense; a multi-document interface; and a simple debugger. The application also includes an implementation of the PowerShell console. But this isn’t just any implementation of the PowerShell console; to name one difference, this console includes true IntelliSense and tab expansion:

PowerShell Plus

That’s right: IntelliSense within the console window itself. Oh and – will wonders never cease? – you can actually paste data into the console window by pressing Ctrl-V! We don’t know about you, but that nearly caused the top of the Scripting Guys’ heads to explode.

PowerShell Plus also includes a handy little Snippet Editor that is tightly integrated with the PowerShell Plus console. What does that mean? Well, within the console press F11; when you do that a list of all your code snippets appears in a handy dropdown list:

PowerShell Plus

Select the snippet, press ENTER, and the code will automatically be pasted into the console. And remember that’s in the console. Oh, if only our old pal Cmd.exe had these capabilities.

PowerGUI

When it comes time to pick out gifts for someone it’s often difficult to find even one thing you think that person might like. When it comes to Windows PowerShell script editors, however, you end up with a very different problem: how do you settle on a single product? (Hint: You know, you don’t have to limit yourself to a single script editor. The more the merrier, right?) We’ve already seen some pretty cool, pretty useful editors. And we haven’t even gotten to PowerGUI yet.

PowerGUI (free download) provides an interesting (and unique) twist on script editors. On the one hand, PowerGUI is a full-fledged script editor, featuring line numbers, IntelliSense, color-coding, step-by-step debugging, etc. But that’s not what makes PowerGUI unique. What makes PowerGUI unique is that the application is more than just a script editor; PowerGUI is also a fully-extensible administrative console.

What the heck does that mean? Well, when you first start PowerGUI you’ll notice a tree control on the left side of the window. If you start clicking that tree control, you’ll see a series of nodes similar to this:

PowerGUI

Now, click on the Processes node and see what happens:

PowerGUI

Well, what do you know: all the processes running on your computer are instantly displayed in a resizable, sortable, and filterable grid.

Nice, huh? Even better, if you click on the PowerShell Code tab, PowerGUI will show you the PowerShell code that produced those results:

PowerGUI

OK, maybe that’s not the most exciting piece of code we’ve ever seen. But you get the idea.

Note. Actually, we should clarify that: PowerGUI shows you the PowerShell code responsible for retrieving the information. PowerGUI takes care of the fancy output and display for you.

As for that part about the administrative console being “full extensible,” that simply means that you can create your own nodes in the tree control. For example, do the following. Inside PowerGUI, right-click the Local System node, point to New, and then click ScriptNode. When the New Script Node dialog box appears, type Installed Software in the Name box. Next, paste the following code into the script editor portion of the dialog box and then click OK:

Get-ChildItem hklm:\software\microsoft\windows\currentversion\uninstall | 
ForEach-Object {Get-ItemProperty $_.pspath}) | 
Select-Object PSChildName, DisplayName, Publisher, DisplayVersion

What was the point of all that? Well, take a look at your screen after you click OK; you should see a list of all the software installed on your computer (or at least the same list you see in Add or Remove Programs):

PowerGUI

Wait; there’s more: right-click your new script node and then click Export. When the Save As dialog appears, type a file name for your script file, making sure to give the file a .snapin file extension (e.g., Software.snapin).

Why is that so cool? Well, now you can share that .snapin file with anyone else who happens to be running PowerGUI. In turn, they can right-click Local System, click Import, and then import your .snapin file to their own PowerGUI. And guess what? You got it: now they can quickly and easily retrieve a list of software running on their computer.

Wow.

Next: Cmdlets and Add-ons