Error when calling 3rd party executable from Powershell when using an IDE

后端 未结 4 1416
悲&欢浪女
悲&欢浪女 2020-11-28 23:41

I have a PowerShell script that uses du.exe (Disk Usage originally from Sysinternals) to calculate the size of directories.

If I run du c:\\Backup in th

4条回答
  •  一整个雨季
    2020-11-29 00:14

    I've recently been facing the same issues, but I would like to get the stderr output directed to stdout. You would think that the following would work:

        & du 2>&1
    

    But PowerShell will interpret the redirection and process it after 'du' is completed. The work-around I found is to invoke it using cmd.exe /c:

        & cmd /c 'du 2>&1'
    

提交回复
热议问题