Record the output of your PowerShell console using Start-Transcript

PowerShell comes with cmdlet of Start-Transcript that can be used to record all the output by commands to a text file. The text file can then be utilized for various reason. My top reason to use Star-Transcript cmdlet is to record all the things while I am building out a new script based on trial-and-error form. This allows me to go back in time and see what commands I ran.

Using Start-Transcript

The syntax is simple, Start-Transcript followed by the name of the file where you want to capture the log

For example

Start-Transcript logme.txt

Once done, you can call the Stop-Transcript. Well this step is optional because it is constantly writing to the text and closing stream.

Stop-Transcript

Following is an example of the execution of this in the cloudshell.

Viewing the contents of the file in cloudshell

You can use the ls command to see the directory listing in cloudshell.

Then you can use your favorite editor to view or edit the file for example, cat, vi or nano

I used nano below to open it in editor

which then launched nano editor

You can press the Ctrl+X to exit this nano editor.

Leave a Reply