1.3. Type Literals

The PowerShell language allows us to access types by using a special syntax called type literals. A type literal is just a type name enclosed in brackets. At their very simplest, type literals return the underlying .NET System.Type object instance:

PS C:\> [System.Int32]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Int32                                    System.ValueType


PS C:\> [System.String]
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object


PS C:\> [System.Diagnostics.Process]

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    Process                                  System.Compon...

We do not really need to repeat that System namespace prefix all the time. Most of the types that we work with ...

Get Pro Windows PowerShell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.