Wednesday, December 21, 2011

PowerShell v3 has some great GUI

When you look at a command-line window – all text, a flashing cursor, and no toolbar or ribbon of any kind – you don’t think that it is a “graphical user interface (GUI).”That’s certainly the case with Windows PowerShell v3, which first shipped with the Windows 8 Developer Preview and which is now available as a Community Technology Preview(part of Windows Management Framework 3.0) that installs on Windows 7. But the real beauty of PowerShellis the fact that, under the hood, it’s neither GUI nor command-line interface (CLI). It’s a little bit of both – and v3 proves it.

A little bit of helpPerhaps you’re a bit confused on how to use the Get-WmiObject cmdlet. Asking for Help Get-WmiObject provides the dense information shown in Figure 1 – which might or might not be helpful, depending on whether or not you can uncross your eyes and make sense of it all.

Figure 1: Help Get-WmiObject Help Get-WmiObject

But run Show-Command Get-WmiObject and a new, GUI-based prompt appears. Each parameter set is broken out onto its own tab, and each parameter is broken out onto its own line. Required parameters have a simple "*" next to their names, and switches are displayed as checkboxes. Easy. When you’re done, you can either run the command or copy it to the clipboard, making it easier to paste it somewhere else and incorporate other commands. Figure 2 shows what it looks like.

Figure 2: Show-Command Get-WmiObject Show-Command Get-WmiObject

Fancy outputPowerShell v3 still includes the handy Out-GridView cmdlet (figure 3), which accepts the output from other cmdlets and constructs a GUI-style table. With clickable column headers for sorting, and with the ability to dynamically filter what’s shown using the built-in “Add criteria” button, this grid view will be all the GUI you need for displaying many different types of output.

Figure 3: Out-GridView cmdlet Out-GridView cmdlet

Better editingThe PowerShell team has made its biggest GUI investments in the new PowerShell Integrated Scripting Environment (figure 4). Finally, we’ve got the pop-up “IntelliSense” code-completion and hinting features we’ve always wanted. The system even shows a brief version of a cmdlet’s help, reminding you what it does and how it’s used.

Figure 4: Integrated scripting environment
Integrated scripting environment

A Commands browser on the right-hand side provides a complete list of every command loaded into the shell, and can be filtered to just include the commands from a particular add-in module like Active Directory. Given that the toughest part about a command-line environment is figuring out what commands you have to work with, this new browser should make it a lot easier to discover and use commands.

Welcome to the WebBut wait: there’s still more GUI to be had in v3, and this time it’s of the Web variety. The new PowerShell Web Access interface is an optional feature that’s installed on a server (Internet Information Services is a pre-requisite for this feature). Once configured, you’ll get a complete Web-based command-line window that’s even pretty usable on a small device like an iPhone. Punch commands into a textbox near the bottom of the screen, hit Enter, and the command executes – with the output displayed in a scrollable, CLI-like window that occupies most of the screen.
I imagine that PowerShell Web Access (PWA) will be installed on a “bridgehead” server within the data center. Since it supports multiple simultaneous connections, any number of administrators could use it to remotely access data center resources, run scripts, execute commands, and otherwise get their jobs done. PWA even supports tab completion, helping to complete cmdlet and parameter names as you type – which is especially welcome when you’re trying to hammer out a long one-liner on your Android phone’s tiny keyboard! You even get a command history, just like you were using the normal PowerShell console.

PWA supports all of the usual IIS authentication mechanisms – digest, basic, integrated, and so forth – and can of course be secured by means of an HTTPS connection, so it looks like it could become a really useful, secure means of giving administrators low-level access to the environment.

It’s a CLI! It’s a GUI! It’s a floor wax!Okay, maybe it won’t shine your floors, but PowerShell v3 is certainly starting to break down the traditional model of a command-line shell. With GUI features in just the right places to make the shell easier to learn, v3 continues to offer plenty of power and expanded reach across a number of administration areas.

By Don Jones