How to capture output in a variable rather than a logfile?

后端 未结 1 566
情话喂你
情话喂你 2021-02-11 13:30

This would write the output to a logfile:

& $Env:WinDir\\system32\\inetsrv\\appcmd.exe >test.log

But what if I wanted to keep the output

相关标签:
1条回答
  • 2021-02-11 14:07

    You have to do:

    $test = & $Env:WinDir\system32\inetsrv\appcmd.exe
    

    If you wanted to redirect error as well, add 2>&1 in the end.

    0 讨论(0)
提交回复
热议问题