User Tools

Site Tools


creating_custom_objects_in_powershell

This is an old revision of the document!


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.1710422588.txt.gz · Last modified: by thomas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki