Suppress console output in PowerShell

前端 未结 3 1188
悲哀的现实
悲哀的现实 2020-12-09 01:04

I have a call to GPG in the following way in a PowerShell script:

$key = & \'gpg\' --decrypt \"secret.gpg\" --quiet --no-verbose > $null
相关标签:
3条回答
  • 2020-12-09 01:45

    It is a duplicate of this question, with an answer that contains a time measurement of the different methods.

    Conclusion: Use [void] or > $null.

    0 讨论(0)
  • 2020-12-09 01:49

    Try redirecting the output to Out-Null. Like so,

    $key = & 'gpg' --decrypt "secret.gpg" --quiet --no-verbose | out-null

    0 讨论(0)
  • 2020-12-09 02:06

    Try redirecting the output like this:

    $key = & 'gpg' --decrypt "secret.gpg" --quiet --no-verbose >$null 2>&1
    
    0 讨论(0)
提交回复
热议问题