Project Description

Save yourself a lot of typing time by creating, editing, and deleting type accelerators in PowerShell. To really get the most from .NET types in PowerShell, leverage type accelerators for one or more entire namespaces using the Use-Namespace command (similar to the using command in C#). PowerShell scripters leveraging Linq, Windows.Forms, and other rich class libraries rejoice!

PowerShell Type Accelerators is a PowerShell module that contains functions facilitating working with type accelerators in PowerShell. The current release includes the following functions:
  • Add-TypeAccelerator (alias:atx)
  • Get-TypeAccelerator (alias:gtx)
  • Set-TypeAccelerator (alias:stx)
  • Remove-TypeAccelerator (alias:rtx)
  • Use-Namespace (alias:use)

News

This module was featured in PowerShell Magazine, in an article titled "A day in the life of a Poshoholic: Creating and using type accelerators and namespaces the easy way".

Requirements

This module requires Windows PowerShell 2.0 or later. It has been verified to work with the beta release of Windows PowerShell 3.0 as well.

Installation and Use

To install the module, download the zip file containing the module, unblock it, then extract it into your Documents\WindowsPowerShell\Modules folder.

To load the module into PowerShell, simply do the following:

PS C:\> Import-Module -Name TypeAccelerator


If that command fails, then you may not have your execution policy configured correctly, the module files may still be blocked, or you may not have copied the files to the right location. Make sure the module directory exists under "%USERPROFILE%\Documents\WindowsPowerShell\Modules"

To get a list of commands exported by the module, invoke the following:

PS C:\> Get-Command -Module TypeAccelerator | Format-Table CommandType,Name


To temporarily use all types in a namespace, invoke the following command:
PS C:\> Use-Namespace -Namespace System.Windows.Forms -ScriptBlock {
    [MessageBox]::Show('Using [System.Windows.Forms.MessageBox]::Show with a type accelerator!') | Out-Null
}

Last edited May 1, 2012 at 4:03 AM by poshoholic, version 7