Tag Archives: pwsh

Remove unneeded characters from ECS / PowerShell cloudwatch logs output

After updating a docker container running on AWS ECS / Fargate, I encountered some erroneous characters in the cloudwatch logs output of the ECS task. When I originally created the dockerfile, the latest version of PowerShell being installed from the Microsoft repo was version 7. The latest container update was running PowerShell 7.2. The amazonlinux container was also updated to the latest version so one of these recent updates within the container had added some leading and trailing characters to the logging output.

Google came up totally empty for me with this one so I am posting this to help out anyone who ends up in the same boat.

The characters showing up in the cloudwatch logs looked like this for the verbose output stream:

[33;1m VERBOSE: Output [0m

And the characters in the standard output stream looked like this:

[32;1m Regular StdOut Output [0m

This line of code added to the top of the script removed all the erroneous characters from the log output.