Functions/Util.ps1
# Color definitions $warningColor = "$([char]0x1b)[33m" # Yellow $infoColor = "$([char]0x1b)[34m" # Blue $errorColor = "$([char]0x1b)[31m" # Red $resetColor = "$([char]0x1b)[0m" function Write-Warning { param ( [Parameter(Mandatory=$true)] [string]$Message, [Parameter(Mandatory=$false)] [bool]$All = $false ) if ($All) { Write-Host "$warningColor$Message$resetColor" } else { if (-not $Message.StartsWith("$warningColor[Warning]$resetColor")) { $Message = "$warningColor[Warning]$resetColor $Message" } Write-Host "$warningColor$Message$resetColor" } } function Write-Info { param ( [Parameter(Mandatory=$true)] [string]$Message, [Parameter(Mandatory=$false)] [bool]$All = $false ) if ($All) { Write-Host "$infoColor$Message$resetColor" } else { if (-not $Message.StartsWith("$infoColor[Info]$resetColor")) { $Message = "$infoColor[Info]$resetColor $Message" } Write-Host "$infoColor$Message$resetColor" } } function Write-Error { param ( [Parameter(Mandatory=$true)] [string]$Message, [Parameter(Mandatory=$false)] [bool]$All = $false ) if ($All) { Write-Host "$errorColor$Message$resetColor" } else { if (-not $Message.StartsWith("$errorColor[Error]$resetColor")) { $Message = "$errorColor[Error]$resetColor $Message" } Write-Host "$errorColor$Message$resetColor" } } |