
- Image via Wikipedia
I gave a presentation at the upstate New York PowerShell user group last night about the new stuff in PowerShell 2 — giving it really made me think about how I’m just so used to PowerShell 2 that I’ve forgotten about how much of it is new in this version — and how cool each of these new things are. In fact, in my list of 7 areas that I talked about, I bet we could find a PowerShell MVP for at least each of the top 6 that would be willing to argue for that one being the most important new feature in PowerShell 2
Having said that, below is the text from my slides … my personal “highlights” of what’s new in PowerShell 2.
What’s New In PowerShell 2?
Advanced Functions
Modules
Help
Remoting
Eventing
Integrated Script Editor (debugging)
Transaction support
… and more
Advanced Functions
Parameter parsing & binding
- Mandatory
- Position
- ValueFromPipeline
- ValueFromPipelineByPropertyName
- ValueFromRemainingArguments
Parameter validation
- IsNull
- IsNotNull
- Set
- Range
- Count
- RegEx Pattern
- Script
Parameter Sets
CmdletBinding Support
- SupportsShouldProcess
- ConfirmImpact
- DefaultParameterSetName
Dynamic parameters
Modules
XCopy deploy (PSModulePath)
Module manifests use .psd1 extension
Script Modules use .psm1 extension
Organization
Private variables and functions
Import modules easily, (and remove)
Related Cmdlets:
- Get-Module
- New-Module
- Import-Module
- Remove-Module
- Export-ModuleMember
Help for Functions and Scripts
XML-based help (just like cmdlets)
Comment-based help
Online help
Provider-based help additions
Get-Help now searches!
- e.g.: man hashtable
Comment-Based Help Example
<#
.SYNOPSIS
A short description of the function.
.DESCRIPTION
A longer description of the function.
.PARAMETER <parametername>
The documentation for that specific parameter
.EXAMPLE
C:\PS> some example code
.LINK
Get-AnotherFunction
.LINK
http://yourwebsite.com/help/documentation
#>
Comment-Based Help Keywords
- Synopsis
- Description
- Parameter
- Example
- Inputs
- Outputs
- Notes
- Component
- Role
- Functionality
- ForwardHelpTargetName
- ForwardHelpCategory
- RemoteHelpRunspace
- Link
- ExternalHelp
Remoting
Fan-in and Fan-out remoting
Requires PowerShell 2.0 on both ends
Receive serialized property bags, not live objects
WinRM = WS-Management = SOAP spec
Enable-PSRemoting requires elevation
Related Cmdlets:
New-PsSession
Get-PsSession
Remove-PsSession
Export-PsSession
Import-PsSession
Enter-PsSession
Exit-PsSession
Invoke-Command
Background Jobs
Execute work asynchronously
Separate runspace
Related Cmdlets:
- Start-Job
- Stop-Job
- Get-Job
- Receive-Job
- Wait-Job
- Remove-Job
- Invoke-Command
Eventing
Finally provides support for asynchronous Events, for GUIs, timers, WMI, and remoting
Events can be forwarded from remote sessions
Related Cmdlets:
- Register-EngineEvent
- Register-ObjectEvent
- Register-WmiEvent
- RegisterUnregister-Event
- Get-EventSubscribers
- New-Event
- Get-Event
- Wait-Event
- Remove-Event
Integrated Script Editor – ISE
Graphical host for PowerShell engine
Tabbed script editor
Supports Unicode!
Supports script debugging (about_debuggers)
Graphical debugging like an IDE
Set breakpoints, stop conditions, etc
Related Cmdlets:
- Set-PSDebug
- Set-StrictMode
- Get-PSCallStack
- Get-PSBreakpoint
- Set-PSBreakpoint
- Remove-PSBreakpoint
- Enable-PSBreakpoint
- Disable-PSBreakpoint
Transaction Support
Commit/rollback semantics
Rollback can be automatic (if error occurs)
Registry provider is only supporter in the box
Related Cmdlets:
- Start-Transaction
- Complete-Transaction
- Undo-Transaction
- Get-Transaction
- Use-Transaction
107 New Cmdlets
- Add-Computer
- Add-Type
- Checkpoint-Computer
- Clear-EventLog
- Clear-History
- Complete-Transaction
- Connect-WSMan
- ConvertFrom-Csv
- ConvertFrom-StringData
- ConvertTo-Csv
- ConvertTo-Xml
- Debug-Process
- Disable-ComputerRestore
- Disable-PSBreakpoint
- Disable-PSSessionConfiguration
- Disable-WSManCredSSP
- Disconnect-WSMan
- Enable-ComputerRestore
- Enable-PSBreakpoint
- Enable-PSRemoting
- Enable-PSSessionConfiguration
- Enable-WSManCredSSP
- Enter-PSSession
- Exit-PSSession
- Export-Counter
- Export-FormatData
- Export-ModuleMember
- Export-PSSession
- Get-ComputerRestorePoint
- Get-Counter
- Get-Event
- Get-EventSubscriber
- Get-FormatData
- Get-HotFix
- Get-Job
- Get-Module
- Get-PSBreakpoint
- Get-PSCallStack
- Get-PSSession
- Get-PSSessionConfiguration
- Get-Random
- Get-Transaction
- Get-WinEvent
- Get-WSManCredSSP
- Get-WSManInstance
- Import-Counter
- Import-LocalizedData
- Import-Module
- Import-PSSession
- Invoke-Command
- Invoke-WmiMethod
- Invoke-WSManAction
- Limit-EventLog
- New-Event
- New-EventLog
- New-Module
- New-ModuleManifest
- New-PSSession
- New-PSSessionOption
- New-WebServiceProxy
- New-WSManInstance
- New-WSManSessionOption
- Out-GridView
- Receive-Job
- Register-EngineEvent
- Register-ObjectEvent
- Register-PSSessionConfiguration
- Register-WmiEvent
- Remove-Computer
- Remove-Event
- Remove-EventLog
- Remove-Job
- Remove-Module
- Remove-PSBreakpoint
- Remove-PSSession
- Remove-WmiObject
- Remove-WSManInstance
- Reset-ComputerMachinePassword
- Restart-Computer
- Restore-Computer
- Select-Xml
- Send-MailMessage
- Set-PSBreakpoint
- Set-PSSessionConfiguration
- Set-StrictMode
- Set-WmiInstance
- Set-WSManInstance
- Set-WSManQuickConfig
- Show-EventLog
- Start-Job
- Start-Process
- Start-Transaction
- Stop-Computer
- Stop-Job
- Test-ComputerSecureChannel
- Test-Connection
- Test-ModuleManifest
- Test-WSMan
- Undo-Transaction
- Unregister-Event
- Unregister-PSSessionConfiguration
- Update-List
- Use-Transaction
- Wait-Event
- Wait-Job
- Wait-Process
- Write-EventLog
Miscellaneous
Try { } Catch{ } Finally { }
Add-Type cmdlet – compiles .NET code
Splatting: @
Steppable pipelines for wrapping cmdlets
-Split and –Join
Script Internationalization
Lots of cmdlet improvements
- Select-String … -NotMatch -AllMatches -Context 3
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=d4980f29-d8c8-452c-8755-7e6fc8b7f8b2)
You forgot one of my favorite new features: proxy functions.
No, I didn’t — it’s there on the last slide as “Steppable pipelines for wrapping cmdlets”
Honestly, when I gave the presentation, I actually mentioned the concept much earlier in the advanced functions section when I was talking about parameter binding and
$PSBoundParameters, and I think they came up somewhere else too (I can’t think where at the moment), but I did give an example during that last slide (although I must admit I did basically no demos in this presentation because of time constraints).[...] showcases some of his favorite new things in PowerShell [...]