Most of out of the box PowerShell commands are returning "complex" objects.
for example, Get-Process returns an array of System.Diagnostics.Process.
All of the function I've ever wrote was returning either a simple type, or an existing kind of object.
If I want to return a home made objects, what are guidelines ?
For example, imagine I have an object with these attributes: Name, Age. In C# I would have wrote
public class Person {
public string Name { get; set; }
public uint Age { get; set; }
}
What are my options for returning such object from a PowerShell function ?
- As my goal is to create PowerShell module, should I move to a c# module instead of a ps1 file ?
- should I compile such objects in a custom DLL and reference it in my module using
LoadWithPartialName? - Should I put my class in a powershell string, then dynamically compile it ?