I have created a test script, test.bat, which contains this:
grep --version | grep --color=always grep
and I have run it both though cmd.exe with the /c option, and pwsh.exe with the -File option.
How come it shows colors when executed through pwsh.exe, but when through cmd.exe, it shows the raw escape sequences without converting to colors?
The script is calling grep, not internal commands, so that there is no shell command differences. You can see in both runs the same version of grep is called. You can see this is happening directly in sequence, in the same console window. You can see when piped through Format-Hex, both outputs look byte identical. Using PowerShell 5 instead of 7 didn't help.
This works just fine on my other Windows 10 machine, and I can't for the life of me figure out why. Maybe I made a configuration change I can't remember? The version of cmd.exe and pwsh.exe are the exact same between the two computers, as are the results when you do $PSVersionTable.