BT

Introducing PowerShell 2

by Jonathan Allen on Sep 12, 2009 |

PowerShell 2 has been in the works for a long time with the first technical preview dating back nearly two years. Here is a small taste of the numerous features they have added since then.

  • Remoting: Cmdlets and Scripts can be executed on remote machines.
  • Background Jobs: Background jobs can be started both locally and remotely using PsJob.
  • ScriptCmdlets: Previously Cmdlets needed to be written in a statically compiled language such as C# or VB. Now they can be written directly in PowerShell script.
  • Steppable Pipelines: Pipelines can be treated like objects with elements being passed in one item at a time.
  • Data Sections: Data sections allow data needed by a script to be separated from the logic itself. In addition to the organizational benefits, this also allows for internationalizing scripts.
  • Script Debugging: Breakpoints can be set on “lines, columns, functions, variables, and commands”.
  • The “splat” operator: The @ operator can be used to pass a collection of key-values pairs as a single parameter.
  • PowerShell ISE: The “Integrated Scripting Environment” is a lightweight IDE that is split into three panes. The top pane is for editing scripts while the lower pane is used for immediately executing individual commands just like from a normal PowerShell prompt. This isn’t really needed though, as the top panel also supports executing highlighted commands just like SQL Server Management Studio.
  • Out-GridView: Instead of just dumping data onto the console, you now have the option to send it to a pop-up window with live grid that supports sorting and filtering.
  • Modules: Modules replace snap-ins as a way to create reusable libraries of cmdlets, scripts, and providers. Unlike Snap-ins, which have to be installed, Modules can be simply copied to a user or system-wide folder. Once there, they can be directly imported by any script that needs them.
  • Events: WMI and CLR events can now be sent to an event queue or bound directly to an action.
  • Transactions: A transactional framework now exists, though currently the only supported provider is for the registry.
  • Error Handling Blocks: The standard try-catch-finally blocks seen in Java, C#, and VB are now available in PowerShell as well.
  • Add-Type: This uses the CodeDOM to compile code fragments from any .NET language.

The release canidate for PowerShell 2.0 is now available on XP and later operating systems.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Warning!!! by Marc Vitalis

If you were able to install this, don't try to do an uninstall. This will mess up your .Net Runtime Optimization service.

Re: Warning!!! by Anders Persson

Tanks for the warning

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT