I want to pass a color parameter to a function to display a message in different colors
function WriteLogColor {
param ([String]$Msg,
$Color)
$TimeStamp = Get-Date -Format "dd/MM/yy HH:mm:ss"
Write-Host "[$TimeStamp] $Msg" -ForegroundColor $Color
}
When calling
WriteLogColor("Hello World", Red)
, the syntax is not correct.
Is it a way to pass a parameter to this function to display strings in different colors ?
Thanks