Then I run Start-Transcript to start logging. When I review the transcript the cmdlet I ran does not align with the custom prompt, but rather a new prompt on the line below it. Here is an example:
Transcript started, output file is C:\Users\xxxx\Documents\PowerShell_transcript.DESKTOP-U995LEF.qwCyiDP8.20180420113112.txt
04/20/2018 11:31:12>
PS>get-process powershell
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
692 31 61116 76268 1.36 11236 1 powershell
Without the custom prompt the executed cmdlet is on the same line as the prompt, example:
Transcript started, output file is C:\Users\Jason\Documents\PowerShell_transcript.DESKTOP-U995LEF.yDgSPx+e.20180420120046.txt PS C:\Temp> get-process powershell
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
747 31 74236 86172 2.03 11236 1 powershell
Is there anyway to use a custom prompt and have start-transcript align the typed commands with the custom prompt?
What you are seeing I believe is expected. PS> means you ran a PowerShell cmdlet or set of commands at the prompt you created.
If you start a new transcript, try switching to command prompt by issuing ‘cmd’ and pressing enter. This will change your shell. to go back to powershell you type ‘exit’ and press enter or open a new shell again by typing ‘powershell’ and pressing enter.
Each of these shells will show up in the transcript, followed by whatever command / output goes with that shell.
Now, if you are wanting your prompt to always be displayed, you may want to look at adding that function to your profile.
This makes a little more sense now. Try adding your custom prompt function to your PowerShell profile (should be in Documents\WindowsPowerShell) ‘profile.ps1’. Once you’ve added it, start a new console and you should see your custom prompt immediately. Then use
Start-Transcript -Path .\transcript.txt
to begin your transcript, followed by whatever cmdlets you want to run. Then
Stop-Transcript
. Then to view the transcript, simply run
notepad .\transcript
and you should see your customized prompt lined up how you want it.
I suppose it’s possible that the transcript commands override the custom prompt somewhat if it doesn’t contain certain characters, though I’d find that odd. Just to see, try prefixing ‘PS’ to the custom prompt and see if it behaves:
Transcript started, output file is C:\Users\Jason\Documents\PowerShell_transcript.DESKTOP-U995LEF.LdPi_BxD.20180420162331.txt
04/20/2018 16:23:31>
PS>get-date
Friday, April 20, 2018 4:23:34 PM
Is it possible to test to see if you have the same results? I’ve tested on two machines and I am getting the same on both, but want to make sure it is not just me.