This is a duplicate of https://serverfault.com/questions/102098/powershell-script-showing-commands-run. I thought it would be more appropriate to ask this question here.
I am playing around with PowerShell scripts and they're working great. However, I am wondering if there is any way to also show all the commands that were run, just as if you were manually typing them in yourself. This would be similar to "echo on" in batch files. I looked at the PowerShell command-line arguments, the cmdlets, but I didn't find anything obvious.
For more info: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-psdebug?view=powershell-6
Note #1: it only records things written to the main console output stream, not Warning / Error / Debug.
Note #2: if you need to record native console applications, you'll need a slight workaround
Start-Transcript doesn't catch any exe output. That's a show stopper for me. I hate to say it but the best way I've found to do this is:
This captures everything AFAICT.
I added -verbose to desired commands. E.g.