User Tools

Site Tools


creating_custom_objects_in_powershell

Creating Custom Objects in Powershell

To more conveniently manage or output data while using Powershell, it is often useful to use custom objects. They can be created as follows:

$Person = [PSCustomObject]@{
    FullName = "Thomas De Reyck"
    Age = 37
    Job = "IT technician"
}

When you output the created object afterwards, we can see our own custom fields:

> $Person
 
FullName        Age Job
--------        --- ---
Thomas De Reyck  37 IT technician
creating_custom_objects_in_powershell.txt · Last modified: by thomas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki