I am running some git commands through PowerShell but I am having issues capturing the output.
Many of the ways I have looked into have failed to c
As I explained here, or here, Git command output are done on stderr, not stdout.
So in your case, you need to pipe stderr.
See "Redirection of standard and error output appending to the same log-file" for instance.
Note: with Git 2.16 (Q1 2018), you can try and set first
set GIT_REDIRECT_STDERR=2>&1
Then stderr should be redirected to stdout.
In "PowerShell - Capturing STDERR Output for Git Commands", the OP Brandon points out to the --porcelain option of (for instance) git push:
& git status --porcelain >> $logFilePath
& git push --porcelain >> $logFilePath
It allows to convert the outputs into a machine readable format and pipe them to the output.