.netpowershelltypesaccelerator

Where can I find a list of Powershell .NET Type Accelerators?


In PowerShell you can use [xml] to mean [System.Xml.XmlDocument]. Do you know where I can find a list of these type accelerators?

Are these accelerators specific to PowerShell or .NET?


Solution

  • See the section entitled Type Name Aliases in this blog post. I believe this is a complete list of the aliases.

    PowerShell Type Alias   Corresponding .NET Type
    [int]                   System.Int32
    [int[]]                 System.Int32[]
    [long]                  System.Int64
    [long[]]                System.Int64[]
    [string]                System.String
    [string[]]              System.String[]
    [char]                  System.Char
    [char[]]                System.Char[]
    [bool]                  System.Boolean
    [bool[]]                System.Boolean[]
    [byte]                  System.Byte
    [byte[]]                System.Byte[]
    [double]                System.Double
    [double[]]              System.Double[]
    [decimal]               System.Decimal
    [decimal[]]             System.Decimal[]
    [float]                 System.Single
    [single]                System.Single
    [regex]                 System.Text.RegularExpression.Regex
    [array]                 System.Array
    [xml]                   System.Xml.XmlDocument
    [scriptblock]           System.Management.Automation.ScriptBlock
    [switch]                System.Management.Automation.SwitchParameter
    [hashtable]             System.Collections.Hashtable
    [psobject]              System.Management.Automation.PSObject
    [type]                  System.Type
    [type[]]                System.Type[]