Wednesday, 31 December 2008

Get-TypeAccelerator.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Gets a list of Type Accelerators in PowerShell and displays them nicely 
  4. .DESCRIPTION 
  5.     This script is based on Osin's blog article and uses the TypeAccelerator 
  6.     class to return the type accelerators contained in PowerShell 
  7. .NOTES 
  8.     Additional Notes, eg 
  9.     File Name  : Get-TypeAccelerator.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : Version 2, CTP3 
  12. .LINK 
  13.     Original article: 
  14.     http://www.nivot.org/2008/12/25/ListOfTypeAcceleratorsForPowerShellCTP3.aspx 
  15.     Script Repository 
  16.     http://www.pshscripts.blogspot.com 
  17. #> 
  18.  
  19. ### 
  20. #   Start of script 
  21. ### 
  22.  
  23. ([type]::GetType("System.Management.Automation.TypeAccelerators"))::Get.GetEnumerator() |   
  24.     Select @{Name="Name"; expression={$_.key}},   
  25.            @{name="Type"; expression={$_.value}} | Sort name | Format-Table -Autosize 
  26. # End of script         

This script produces the following output:

PS C:\foo> .\Get-TypeAccelerator.ps1'

Name            Type
----            ----
adsi            System.DirectoryServices.DirectoryEntry
adsisearcher    System.DirectoryServices.DirectorySearcher
array           System.Array
bool            System.Boolean
byte            System.Byte
char            System.Char
decimal         System.Decimal
double          System.Double
float           System.Single
hashtable       System.Collections.Hashtable
int             System.Int32
ipaddress       System.Net.IPAddress
long            System.Int64
powershell      System.Management.Automation.PowerShell
pscustomobject  System.Management.Automation.PSObject
psmoduleinfo    System.Management.Automation.PSModuleInfo
psobject        System.Management.Automation.PSObject
ref             System.Management.Automation.PSReference
regex           System.Text.RegularExpressions.Regex
runspace        System.Management.Automation.Runspaces.Runspace
runspacefactory System.Management.Automation.Runspaces.RunspaceFactory
scriptblock     System.Management.Automation.ScriptBlock
single          System.Single
string          System.String
switch          System.Management.Automation.SwitchParameter
type            System.Type
wmi             System.Management.ManagementObject
wmiclass        System.Management.ManagementClass
wmisearcher     System.Management.ManagementObjectSearcher
xml             System.Xml.XmlDocument

0 comments: