Finding Useful .NET Types

by Apr 4, 2016

You may have heard about "type accelerators": they are shortcuts for the long .NET type name:

 
PS> [XML]

IsPublic IsSerial Name                                     BaseType                                                                                                      
-------- -------- ----                                     --------                                                                                                      
True     False    XmlDocument                              System.Xml.XmlNode                                                                                            



PS> [XML].FullName
System.Xml.XmlDocument

PS> [Xml] -eq [System.Xml.XmlDocument]
 

Most .NET types that are frequently used in PowerShell have a predefined "type accelerator". By reading out the type accelerators, you get a nice list of frequently used .NET types:

#requires -Version 2

$t = [PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')
$t::Get.GetEnumerator() | 
  Where-Object {$_.Value.Name -notlike '*Attribute*'} | 
  Out-GridView

Twitter This Tip! ReTweet this Tip!