Powershell Custom Object Formatting
Today I would like to share some guidelines on how to apply formatting to custom powershell objects. There are many times when writing advanced functions, cmdlets and modules where a custom object is very useful, so let's start by creating an object type for our custom objects. Creating a type is very simple, you just define the type as you would in C# and then add it: add-type @' namespace TestModule.CustomObject { public class ExchangeServerMaintenanceMode { public string Name; public bool Enabled; public int ID; } } '@ I should also add here that Powershell 5 makes it even easier by allowing us to create classes directly! Now that we have added the type of our custom object, lets create some objects! $myuser = New-Object TestModule.CustomObject $myuser .Id = "1" $myuser .Name = "User1" $myuser .Enabled = $false Here, we have created a new object of type TestModule.CustomObject and we...