I searched on Stack Overflow and Google but couldn't find an answer to my question:
Which data types (e.g. string
, XML
, regex
, int
etc.) does PowerShell have? There seems to be no list on Microsoft TechNet and I found no way to simply list them all.
As already hinted by PetSerAl, the type system in PowerShell is a direct extension of the .NET CTS - any .NET type loaded into the AppDomain currently hosting your PowerShell environment can be used.
In .NET, types (classes, structs, enums and builtin value types) are compiled into assemblies (usually in the form of a .dll
file).
If you want an exhaustive list of those, you can simply enumerate all assemblies currently loaded into memory, then enumerate all the types in said assemblies:
[AppDomain]::CurrentDomain.GetAssemblies() |Foreach-Object {
$_.GetExportedTypes()
}
If you just want a list of all the Type Accelerators (the shortname aliases like [regex]
,[wmi]
, [adsi]
etc.), you can use the following trick:
$AcceleratorType = [psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
$AcceleratorType::Get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With