1

When I run this command in Powershell it outputs with colour.

(curl wttr.in -UserAgent curl).Content

However when I run the same command in the Windows CMD, I get the same output but with no colour.

powershell (curl wttr.in -UserAgent curl).Content

How do I run a Powershell command in the Windows CMD and get the output in colour as it would display in Powershell?


demo

8
  • 3
    My first question would be why are you regressing to cmd? Why not just stay in Powershell. Next I would point out that this cannot be done in a standard cmd.exe console.
    – EBGreen
    Jul 17, 2018 at 12:30
  • My preference is to use the standard Windows CMD. Can you provide an explanation as to why it is not possible?
    – u01jmg3
    Jul 17, 2018 at 12:46
  • Because the standard cmd.exe does not provide hooks for programatically changing the color of the output. Actually that is not entirely true. Starting with Win 10, cmd.exe does support standard ANSI escape sequences. So I suppose that you could write a batch file that takes the output of the powershell command, reparses it it then changes the colors for output. Or alternatively you could use the newer technology.
    – EBGreen
    Jul 17, 2018 at 12:54
  • Appreciate the explanation. Can you provide any more clarity on what would be required in terms of reparsing the Powershell output (especially as Win10 now supports standard ANSI escape sequences)? Even one example just to get me going.
    – u01jmg3
    Jul 17, 2018 at 13:42
  • 1
    probably some problem with your cmd settings, because it works without problem in my place. Anyway, very interesting link
    – phuclv
    Jul 17, 2018 at 14:14

0

You must log in to answer this question.

Browse other questions tagged .