I'm using the following PowerShell task:
2022-12-09T04:30:32.5910772Z Task : PowerShell 2022-12-09T04:30:32.5911006Z Description : Run a PowerShell script on Linux, macOS, or Windows 2022-12-09T04:30:32.5911196Z Version : 2.212.0 2022-12-09T04:30:32.5911349Z Author : Microsoft Corporation 2022-12-09T04:30:32.5911615Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
Here is an example warning output where you can see the message is surrounded by [33;1m
and [0m
. I assume these are ANSI escap codes.
2022-12-09T04:30:30.8803823Z [33;1mWARNING: The provided service principal secret will be included in the 'AzureRmContext.json' file found in the user profile ( /root/.Azure ). Please ensure that this directory has appropriate protections.[0m
Here is an example Error message output:
2022-12-09T04:30:39.5319115Z [91mInvoke-RestMethod: [0m/azp/agent/_work/r2/a/_ADsync-Utility/adsync/ADsyncUtility/adbusersync.ps1:254
2022-12-09T04:30:39.5320715Z [96mLine |
2022-12-09T04:30:39.5322096Z [96m 254 | [0m … sResponse = [96mInvoke-RestMethod $adbGroupsURL -Method GET -Headers $adb[0m …
2022-12-09T04:30:39.5323707Z [96m | [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-12-09T04:30:39.5325002Z [91m[96m | [91m{"error_code":"403","message":"Invalid access to Org:
2022-12-09T04:30:39.5326245Z [96m | [91m2660194586577136"}
2022-12-09T04:30:39.5327021Z [0m
As a workaround, is there a way that I can configure the format of Powershell Write-Verbose, Write-Warning and Write-Error cmdlets' messages to remove these escape codes and/or possibly use the Azure DevOps Logging Command Formatting syntax?
- ##[warning]Warning message
- ##[error]Error message