How to do it...

Install and start PowerShell Core and execute the following steps:

  1. All streams can be redirected, thereby creating a new file, as in the following example:
Get-Item -Path $home,'nonexistant' 2> error.txt 1> success.txt
Get-Content -Path error.txt, success.txt
  1. You can also append different streams to files by using the >> operator:
Get-Item -Path $home,'nonexistant' 2>> error.txt 1>> success.txt
Get-Content -Path error.txt, success.txt
  1. Streams can also be combined into the output by using the >&1 operator:
# This helps e.g. with misbehaving external applications
Get-Module -Verbose -List -Name 'PackageManagement','nonexistant' 2>&1 4>&1
  1. Combining streams into the output will pollute the output, however:
$modules = Get-Module -Verbose -List -Name 'PackageManagement','nonexistant' 2>&1 4>&1
$modules.Count # This should contain only one...
$modules[0] # This definitely doesn't look like a module