function Format-UnderlineText { <# .SYNOPSIS Get text formatted for underline if the system supports it. .PARAMETER Text The text to apply formatting to. #> [CmdletBinding()] [OutputType([string])] param ( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] [string]$Text ) if (Test-TerminalSupportsANSIEscapes) { return "$($PSStyle.Underline)$Text$($PSStyle.UnderlineOff)" } else { return $Text } }