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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.