Private/Write-FSMStatus.ps1
|
function Write-FSMStatus { <# .SYNOPSIS Writes a colour-coded status line to the host for clear operator feedback. .DESCRIPTION Provides consistent, colour-coded console messaging across the module so a migration run reads cleanly at a glance: cyan for information, green for success, yellow for warnings/previews, red for failures. Write-Host is used deliberately here: this output is host-only UI, not data. All actual results are returned as objects through the pipeline so they can still be captured, filtered, and logged. The PSScriptAnalyzer rule is suppressed below with that justification. .PARAMETER Message The text to display. .PARAMETER Level Information, Success, Warning, or Error. Controls the colour and prefix. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Host-only operator UI; data is returned via the pipeline.')] [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Message, [ValidateSet('Information', 'Success', 'Warning', 'Error')] [string]$Level = 'Information' ) $map = @{ Information = @{ Colour = 'Cyan'; Prefix = '[i]' } Success = @{ Colour = 'Green'; Prefix = '[+]' } Warning = @{ Colour = 'Yellow'; Prefix = '[!]' } Error = @{ Colour = 'Red'; Prefix = '[x]' } } $style = $map[$Level] Write-Host ("{0} {1}" -f $style.Prefix, $Message) -ForegroundColor $style.Colour } |