Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


June 2009

New Features in Windows PowerShell 2.0

Remoting, script debugging, and other features fill PowerShell gaps
RSS
Subscribe to Windows IT Pro | See More Scripting Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Executive Summary:
The release of Windows PowerShell 2.0 will add important new features to the PowerShell language and development experience, including new cmdlets, variables, and operators. The ability to run background jobs and for administrators to create ScriptCmdlets makes PowerShell 2.0 more versatile. Script degugging capabilities are enhanced both through cmdlet-based debugging and the Integrated Scripting Environment.

If you've wanted to take advantage of PowerShell scripting but found the learning curve a bit too steep, PowerShell 2.0 might be just the ticket you've been waiting for. Expected to be released in the second half of 2009, PowerShell 2.0 adds several important new features to the PowerShell language and development experience that make it easier to use as well as filling in some of the gaps that were present in PowerShell 1.0. My top ten favorite new features in PowerShell 2.0 follow.

10. New cmdlets—PowerShell 2.0 includes 24 new cmdlets. Some of the cmdlets work with debugging, Windows Management Instrumentation (WMI), and background jobs. Out-GridView is one of my favorites; this cmdlet displays the results of other commands in an interactive table so that you can sort and search the data displayed.

9. New operators—PowerShell 2.0 provides three useful new operators: @ (pronounced splat), -split, and -join. The @ operator passes a collection of parameters; -split breaks a string into an array; and -join concatenates multiple strings, adding separators.

8. New built-in variables—PowerShell 2.0 includes four new built-in variables: $commandLineParameters, $PSVersionTable, $Culture, and $UICulture. The $commandLineParameters variable accesses command line parameters. $PSVersionTable reports the current PowerShell version. $Culture and $UICulture report the current culture (i.e., the language setting on the target system) and UI culture information.

7. Try-Catch-Finally exception handling—Following in the footsteps of the other .NET languages, PowerShell 2.0 adds the standard Try-Catch-Finally structure to the PowerShell language. You use the Try block to safely execute one or more statements. If an error occurs, the code in the Catch block will be executed. An optional Finally block contains code that is run after the Try-Catch portion completes.

6. PowerShell Hosting APIs—Microsoft has included PowerShell scripting support in all its recent server products, including Exchange Server 2007, SQL Server 2008, and Windows Server 2008, as part of its Common Engineering Criteria. The new PowerShell Hosting APIs promise to extend PowerShell functionality to other products because it simplifies hosting PowerShell in applications.

5. Script debugging—Another important improvement in PowerShell 2.0 is its enhanced debugging capabilities. PowerShell 2.0 has a cmdlet-based debugger that lets you set breakpoints and step through your scripts using the PowerShell console window without needing any graphical development tools. To find out more about PowerShell 2.0's script debugging, run the command

get-help about_debugger 

4. Background jobs—One of the biggest gaps in PowerShell 1.0 is the inability to run a background process. This made it tough to replace those Windows Shell scripts that made use of the Start command. PowerShell 2.0's new Start-PSJob cmdlet asynchronously runs background jobs on the local system or on remote systems. For more information, you can run

get-help about_psjob 

3. ScriptCmdlets—In PowerShell 1.0, you need to program in .NET to create new cmdlets. This requirement means that typically only developers can make new cmdlets. Powershell 2.0 lets administrators create ScriptCmdlets using PowerShell itself. For more information about creating ScriptCmdlets, run

get-help about_scriptcmdletparameters
get-help about_scriptcmdletmethods

2. Remoting—One of the most important changes in PowerShell 2.0 is support for running scripts on remote systems. PowerShell Remoting lets you run scripts on remote networked systems. This new remoting support requires that PowerShell 2.0 be installed on both the local and remote systems. For more information, run

get-help about_remoting 

1. Integrated Scripting Environment—My favorite PowerShell 2.0 feature is the new Integrated Scripting Environment. ISE is a multitabbed graphical PowerShell development platform that features color-coded syntax. It also includes debugging capabilities that let you set breakpoints and step through your PowerShell scripts. If you've had trouble getting started with PowerShell, ISE will definitely kick start your PowerShell scripting.

End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Understanding File-Size Limits on NTFS and FAT

A general confusion about files sizes on FAT seems to stem from FAT32's file-size limit of 4GB and partition-size limit of 2TB. ...


Related Articles Use PowerShell to Execute Commands on Remote Machines

Type Accelerators: A Useful But Undocumented Feature in PowerShell 1.0

Book Updated for Windows PowerShell 2.0

Features of PowerGUI Script Editor

Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events WinConnections and Microsoft® Exchange Connections

Deep Dive into Windows Server 2008 R2 presented by John Savill

PowerShell 201 - eLearning Series with Paul Robichaux

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement