I am trying to run .NET locally. When I use dotnet watch run command and when I do something in Swagger UI I get a lot of output text in the PowerShell console. I want to color words as info and error when I use them and when they appear in the output.
I tried using PowerShell profile. This is where I ended up but it is not working.
function coloredText{
    $output = Invoke-Expression $input
    
    foreach ($line in $output) {
        $coloredLine = $line -replace 'info', "$(Write-Color -Text 'info' -ForegroundColor Blue)"
        Write-Host $coloredLine
    }
}
# Define an alias for the command to be execute with the function
Set-Alias -Name "dotnet watch run" -Value "dotnet watch run | coloredText"
# Call Out-Default to execute the function on every change in the output
Out-Default 
 
     
    