PowerShell Community Extensions and PowerShell Plus

Both PowerShell Community Extensions and PowerShell Plus are important additions to your Windows PowerShell environment. In this excerpt from "Essential PowerShell" you'll learn how to download and install both, as well as the process of testing and using them.

Essential PowerShell This chapter excerpt from Essential PowerShell, by Holger Schwichtenberg, is printed with permission from Addison-Wesley Professional, Copyright 2008.

Click here to purchase the entire book.

About the author


WPS 1.0 includes only 129 commandlets. You might ask why I wrote only. You will notice soon that the most important commandlets are those with the verbs get and set. And the number of those commandlets is quite small compared to the large number of objects that Windows operating systems provide. All the other commandlets are, more or less, related to WPS infrastructure (for example, filtering, formatting, and exporting).

PowerShell Community Extensions (PSCX) is an open source project (see Figure 1.11) that provides additional functionality with commandlets such as Get-DhcpServer, Get-DomainController, Get-MountPoint, Get-TerminalSession, Ping-Host, Write-GZip, and many more. Microsoft leads this project, but any .NET software developer is invited to contribute. New versions are published on a regular basis. At the time of this writing, version 1.1.1 is the current stable release.

DOWNLOAD POWERSHELL COMMUNITY EXTENSIONS
www.codeplex.com/PowerShellCX

PSCX is provided as a setup routine that should be installed after WPS has been installed successfully.

Figure 1.11 (click to enlarge)

You can incorporate additional functionality of PSCX into WPS by using a profile script (see Figure 1.12). Just copy this profile script to your My Documents/Windows PowerShell directory, if you want, during PSCX setup. As a beginner, you should use this option.

Figure 1.12 (click to enlarge)

Testing the PowerShell Extensions

The installation of PSCX changes the WPS console just a bit. Instead of the current path, the prompt now contains a counter. However, the path does display in the window's title.

Start WPS and type Get-DomainController (if your computer is a member of an Active Directory) or test PSCX by using Ping-Host with any computer on your network (see Figure 1.13).

Figure 1.13 (click to enlarge)

Downloading and Installing the PowerShellPlus

Unfortunately, Microsoft does not provide a script editor for WPS yet. However, a few third-party editors support WPS (see Chapter 9, "PowerShell Tools"). Throughout this book, we use PowerShellPlus Editor, which is free for noncommercial use.

A previous editor called PowerShell IDE from the same author was free even for commercial use. However, PowerShell IDE never made it to a final release and was discontinued.

The PowerShellPlus Editor is part of PowerShellPlus. PowerShellPlus consists of the editor and a console that provides IntelliSense while using the PowerShell interactively.

POWERSHELLPLUS WEBSITE www.powershell.com

PowerShellPlus does not need any setup. It is a true .NET application with XCopy deployment. You just unpack the ZIP file to the directory of your choice and start the PowerShellPlus.exe that is part of the package.

Testing the PowerShell Editor

Figure 1.14 (click to enlarge)

To use the PowerShellPlus in script mode, click Code Editor and create a new script file (New/PowerShell Script) or open an existing script PS1 file (Open). Now open the script file CreateUser.ps1 that you created earlier. You will see line numbers, and you will encounter the same IntelliSense features that you have in interactive mode. To run the script, click the Run symbol in the toolbar (see Figure 1.15). The result will display in the interactive Windows in the background.

WARNING Make sure the user account does not exist before running the script. Otherwise the script will fail with the error "The account already exists."

Figure 1.15 (click to enlarge)

Another great feature is debugging. Place the cursor on any line in your script and click the Debugging icon. Next, go to any line and press F9. This creates a red circle next to that line, called a breakpoint. Now run the script. You will see the PowerShellPlus Editor executing the script in slow motion, marking the current line yellow and stopping at the line with the breakpoint (see Figure 1.16). In the Variables Inspector window, you can inspect the current value of all variables. In the interactive window, you can type any WPS command that will be executed within the current context. That is, you can interactively access all script variables. To continue the script, press F8 or click the Continue icon in the toolbar.

Figure 1.16 (click to enlarge)

Code snippets are also a nice feature of the PowerShellPlus. In a script file, click Snippet/Insert on the toolbar or select Insert Snippet in the context menu in the main Editor window. You will be able to select a snippet. You can create you own snippets with the PowerShellPlus (via Snippets/ New on the toolbar).


ESSENTIAL POWERSHELL

What is PowerShell?
Downloading and Installing PowerShell
PowerShell Community Extensions and PowerShell Plus

 Part 1:  Part 2:  Part 3:
Dr. Holger Schwichtenberg is one of Germany's well-known experts for .NET and Windows Scripting technologies, is a Microsoft MVP, a .NET Code Wise Member, a board member of codezone.de, MSDN Online Expert, and a INETA speaker. He has published more than 20 books for Addison Wesley and Microsoft Press in Germany, in addition to more than 400 journal articles, notably for the IT journals iX, DOTNET Pro, and Windows IT Pro. He can be reached at hs@powershell24.com.

The PowerShellPlus has, according to the WPS console, two modes: an interactive mode and a script mode (see Figure 1.14). After starting the PowerShellPlus, you will see the interactive mode. You can use any commandlet (or pipeline). When you press Return, the commandlet is executed, and the result displays in the same window. The handy feature is the IntelliSense. If you enter Get-P, you will see a drop-down list of the available commandlets that start with these letters.
This was first published in September 2008

Dig deeper on Server Hardware for Windows

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close