Share via


Windows PowerShell: Meet the New Shell

If you haven’t seen the new Windows PowerShell version 3 yet, you should make a point to check it out.

Don Jones

The new Windows PowerShell is coming. Actually, Microsoft has just launched a Community Technology Preview (CTP) of Windows PowerShell version 3, although the final version 3 probably won’t ship until it comes out with Windows 8. It also will be available for Windows 7 and Windows Server 2008 R2. The CTP will install on those OSes.

A CTP is an excellent point in the development cycle for you to start experimenting with new Microsoft technology. Product teams can still accept and act on feedback. Don’t like some new piece of syntax? Say something. Wish a feature did just one more useful thing? Let them know.

For Windows PowerShell, that feedback is usually best sent through Microsoft Connect, a site that’s being used by more and more product teams. That can seem like a black hole, because in many cases Microsoft can’t tell you what they’re doing with your feedback until they’ve shipped the next version of the product. The Windows PowerShell team does indeed read that stuff, though. In fact, there’s a whole mess of improvements in version 3 that came directly from suggestions on Connect.

CLI with a GUI

Here are some of the highlights of what you’ll find in the CTP. Newcomers often have difficulty with Windows PowerShell syntax. For example, if they want to retrieve all of the “svchost” processes, they’ll run something like Get-Process –svchost. In this case, they should instead run Get-Process –name svchost.

The parameter thing can take a bit of getting used to. In version 3, however, the new Show-Command cmdlet helps make it more obvious what you’re supposed to do. Start by running Show-Command “Get-Process” and you’ll be rewarded with a pop-up dialog box (see Figure 1).

Figure 1 New dialog boxes make it clear where you need to enter what information.

This makes it much more obvious what you are supposed to type and where. The labels in the GUI correspond to the cmdlet parameter names. Each tab represents one of the cmdlet’s parameter sets, which helps you distinguish between them.

Once you enter “svchost” (or whatever you’re looking for) into the Name field, you can click a button and it will run. Better yet, copy the complete command to the clipboard so you can see it properly typed out. It’s a fantastic learning tool.

A Better Editor

The Integrated Scripting Environment (ISE) is also vastly improved in version 3 (see Figure 2). It now offers IntelliSense code hinting and completion, pop-up syntax reminders and more. There’s an add-ins sidebar that presents additional visual tools, such as the native command list. It’s an incremental set of improvements, but they go a long way toward making the ISE more polished and usable.

Figure 2 There’s a vastly improved screen editor in Windows PowerShell version 3.

Better Command Discovery

You couldn’t find a command using the built-in help system in version 2. Nor could you use any of the other discoverability mechanisms until you had installed the module containing that command into memory. That made it tough to find add-in commands. In version 3, the shell auto-discovers modules within its defined module paths—defined in the PSModulePath environment variable, to be precise.

In Figure 2, you’ll notice commands like Get-ADComputer, even though there’s no ActiveDirectory module loaded. If I’d tried to run one of those unloaded commands, Windows PowerShell would’ve invisibly loaded it in the background.

This new discovery mode gives you the advantage of loading every single available module right when the shell starts. And it does so without incurring the expected time lag or memory hit. You’ll still only load what you’re using, but at least now you have a way to find commands that don’t load into memory on startup. Thanks to that auto-discovery, it will be much easier to learn Windows Server 8, which will ship with hundreds of additional commands spread across 80 or so modules.

Welcome to the Web

Version 3 also introduces Windows PowerShell Web Access. I’d imagine we’ll all be calling this “PWA” in the coming months. You can see some great examples of how this feature works on MVP Jan Egil Ring’s blog.

Essentially, this is an IIS-based Web site that offers a Web-ified version of the shell’s console window. You get a text box at the bottom of the screen in which you type your commands. Those commands are then executed on the Web server. It’s friendly enough to smartphones as well. It even supports tab completion, like the regular console, to make typing a bit easier (which is much appreciated on my iPhone).

So now, in your datacenter, you can set up a sort of “Windows PowerShell Proxy.” You can connect to this from any device at any time to kick off commands. Because it’s hosted within IIS, it supports all of the IIS authentication mechanisms, including Kerberos and CredSSP. You can also secure it with HTTPS.

This means it can impersonate your credentials and run commands on your behalf, rather than trying to do so through some limited or super-powerful account. This feature was previously available only through some commercial third-party add-ons, or your own customization.

There’s other Web connectivity for Windows PowerShell as well. You can expose a given set of Windows PowerShell cmdlets as a REST-based Web service. This makes it easy to consume those cmdlets from Web applications or other apps—even with non-Windows machines.

More Shell Goodness

There’s a lot more in version 3—workflows, time- and event-triggered scheduled jobs, simplified syntax for certain commands, and more robust Remoting connectivity. The syntax is still evolving, but the CTP comes with oodles of examples to get you going. You should dive right in.

Don_Jones

Don Jones* is a Microsoft MVP Award recipient and author of “Learn Windows PowerShell in a Month of Lunches” (Manning Publications, 2011), a book designed to help any administrator become effective with Windows PowerShell. Jones also offers public and on-site Windows PowerShell training. Contact him through his Web site at ConcentratedTech.com.*

Related Content