Contact Info

Crumbtrail

ActiveXperts.com » Administration

Windows PowerShell Main Features

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

Modules allow script developers and administrators to partition and organize their Windows PowerShell code in self-contained, reusable units. Code from a module executes in its own self-contained context and does not affect the state outside of the module. Modules also enable you to define a restricted runspace environment by using a script.

  • 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

  • XML-based help (just like cmdlets)
  • Comment-based help
    • 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
  • Online help
  • Provider-based help additions
  • Get-Help now searches! o e.g.: man hashtable

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

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

ISE - Integrated Scripting Editor

Integrated Scripting Environment (ISE) is a host application for Windows PowerShell, in it you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface with multiline editing, tab completion, syntax coloring, selective execution, context-sensitive help, and support for right-to-left languages. You can use menu items and keyboard shortcuts to perform many of the same tasks that you would perform in the Windows PowerShell console. For example, when you debug a script in the Windows PowerShell ISE, to set a line breakpoint in a script, right-click the line of code, and then click Toggle Breakpoint.

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