Type accelerators
A type accelerator is an alias for a type. At the beginning of this chapter, the System.Management.Automation.PowerShell
type was used; this type has an accelerator available. The name of the type accelerator is simply PowerShell. The type accelerator allows the following to be used:
[PowerShell].Assembly
Another commonly used example is the ADSI accelerator. This represents the System.DirectoryServices.DirectoryEntry
type. This means that the following two commands are equivalent:
[System.DirectoryServices.DirectoryEntry]"WinNT://$env:COMPUTERNAME"
[ADSI]"WinNT://$env:COMPUTERNAME"
The full type name behind a type accelerator can be seen using the FullName
property:
PS> [ADSI].FullName
System.DirectoryServices.DirectoryEntry
PowerShell includes a lot of type accelerators; these accelerators are documented in about_Type_Accelerators
:
Get-Help about_Type_Accelerators
Getting and adding type accelerators in code is explored later in this...