A type accelerator is an alias for a type name. At the beginning of this chapter the System.Management.Automation.PowerShell
type was used. This type has an accelerator available. The accelerator allows the following notation to be used:
[PowerShell].Assembly
Another commonly used example is the ADSI
accelerator. This represents the type System.DirectoryServices.DirectoryEntry
. The following two commands are equivalent:
[System.DirectoryServices.DirectoryEntry]"WinNT://$env:COMPUTERNAME"
[ADSI]"WinNT://$env:COMPUTERNAME"
Getting the list of type accelerators is not quite as easy as it should be. An instance of the TypeAccelerators
type is required first. Once that has been retrieved, a static property called Get
will retrieve the list; the first few results are shown following:
$type = [PowerShell].Assembly.GetType('System.Management.Automation.TypeAccelerators')
$type::Get
New accelerators may be added; for example, an accelerator for the TypeAccelerators
class would make...