How to output objects from your own PowerShell functions

This example of PowerShell code shows how to output objects from your own functions. The basic tasks you do to accomplish this in your function are:

  1. Assemble the values into a hash table
  2. Create an object using that hash table
  3. Output the object

Once you do this, then you can treat your output as you would any other object in PowerShell.

  1. Assemble the values into a hash table
    • See my example below, it is the lines like $Properties =  @{…}
    • More info at about_Splatting
  2. Create an object using that hash table
    • See my example, the line starting with $Object = New-Object…
  3. Output the object
    • Simply Write-Output $Object

1 thought on “How to output objects from your own PowerShell functions”

Leave a Reply

Your email address will not be published. Required fields are marked *