Formatting Text Output

by Dec 15, 2017

If you’d like to nicely format output text, you may want to use a PSCustomObject and output it as a formatted list like so:

$infos = [PSCustomObject]@{
    Success = $true
    Datum = Get-Date
    ID = 123

}

Write-Host ($infos| Format-List | Out-String) -ForegroundColor Yellow

Simply add and adjust keys and values in your hash table.

Twitter This Tip! ReTweet this Tip!