Private/Write-SinglePair.ps1
function Write-SinglePair { <# .SYNOPSIS Writes a label-value pair to the console with specific colors and optional label alignment. .DESCRIPTION This function writes a label-value pair to the console with specified colors for the label and value. It also allows for optional alignment of the label by padding it to a maximum length. .PARAMETER Label The label to be displayed. .PARAMETER Value The value to be displayed. .PARAMETER LabelColor The color of the label text. Defaults to 'DarkCyan'. .PARAMETER ValueColor The color of the value text. Defaults to 'DarkGray'. .PARAMETER MaxLabelLength The maximum length of the label, used for padding and alignment. .EXAMPLE Write-SinglePair -Label 'Name' -Value 'John Doe' -LabelColor 'Green' -ValueColor 'Red' .EXAMPLE Write-SinglePair -Label 'Age' -Value '30' -MaxLabelLength 10 .NOTES Author: owen.heaume Version: 1.0.0 - Initial release #> param ( [Parameter()] [string]$Label, [Parameter()] [string]$Value, [string]$LabelColor = 'DarkCyan', [string]$ValueColor = 'DarkGray', [int]$MaxLabelLength ) $alignedLabel = $Label.PadLeft($MaxLabelLength) Write-Host "$alignedLabel " -ForegroundColor $LabelColor -NoNewline Write-Host "$Value" -ForegroundColor $ValueColor } |