According to this TechNet article about PowerShell type accelerators, there are several dozens of type aliases called type accelerators. Indeed, the following command
[psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::get
returns 80 accelerators on my system.
However, the shorthand for it [accelerators]::get
seems to fail:
Unable to find type accelerators. Make sure that the assembly that contains this type is loaded. At line:1 char:1
+ CategoryInfo : InvalidOperation: (accelerators:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound
I have also tried to dynamically load System.Management.Automation.TypeAccelerators
assembly with [System.Reflection.Assembly]::LoadWithPartialName("System.Management.Automation.TypeAccelerators")
before issuing the command, but it still fails.
$PSVersionTable
returns the following data:
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.18728
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
The OS is Windows 7 x64.
How can I get the PowerShell type accelerator list in an accelerated way?
I know the article says it's present by default in PowerShell 3.0, but I've never seen it in any other version out of the box, was likely removed again for the 4.0 release.
You'll need to add it yourself:
$TAType = [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
$TAType::Add('accelerators',$TAType)
# this now works
[accelerators]::Get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With