$outFile = New-TemporaryFile
$errFile = New-TemporaryFile
command > $outFile 2>$errFile
$out = Get-Content $outFile
$err = Get-Content $errFile

This is useful when writing Git Hooks. One use case is pre-commit hook to validate a file before commiting it in case of a blackboxed application outputs errors but gives the exit code of 0. In this situation, the hook has to validate with the stderr not with the exit code. For example, the hook would be like below:

If ($err.Length -ne 0) {
  Exit 1
Exit 0