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.