Wednesday, December 2, 2009

Listing all PowerShell type accelerators

Type accelerators are shortcuts (similar to aliases) for .NET type names.

For example:


Are equivalent because there is a type accelerator that maps int to System.Int32. They can be very useful when dealing with longer type names such as System.Text.RegularExpressions.Regex ([regex]).

The way to list all the currently defined type accelerators is:

([type]::gettype("System.Management.Automation.TypeAccelerators"))::get | sort key

TypeAccelerators also has an Add function that can be used to define new type accelerators.


Post a Comment