How to pipe the output of a command to a file without powershell changing the encoding?

后端 未结 3 640
面向向阳花
面向向阳花 2021-01-20 02:50

I want to pipe the output of a command to a file:

PS C:\\Temp> create-png > binary.png

I noticed that Powershell changes the encoding

3条回答
  •  野性不改
    2021-01-20 03:16

    Create a batchfile containing the line

    create-png > binary.png
    

    and call that from Powershell via

    & cmd /c batchfile.bat
    

    If you'd rather pass the command to cmd as command line parameter:

    $x = "create-png > binary.png"
    & cmd /c $x
    

提交回复
热议问题