Monday, April 30, 2018

How do you create a custom object in PowerShell?

One way to create a custom object is by using the New-Object cmdlet.

This cmdlet creates an instance of a .NET Framework or COM object.

Here is simple example:
-----------
$obj = New-Object PSObject -Property @{    
       F_Name = "Sam"    
       L_name="Luxton"
       Age = 50
       Email="S_Luxton@gmail.com"
       }

------------------------------
The image shows the response:


Custom_Object_0

You can 'parse' the object as shown in the next image.



No comments: