Skip to content

Instantly share code, notes, and snippets.

@bsdayo
Created November 11, 2024 02:43
Show Gist options
  • Save bsdayo/e66e39e8a2171269b145074f74539bab to your computer and use it in GitHub Desktop.
Save bsdayo/e66e39e8a2171269b145074f74539bab to your computer and use it in GitHub Desktop.
Capture both stdout and stderr to separate variables
$err = ($out = somecommand) 2>&1
# Type of $out is string[] if present
# Type of $err is ErrorRecord if present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment