SID-500

Home » PowerShell » PowerShell: Documenting your work with Start-Transcript

PowerShell: Documenting your work with Start-Transcript

Start-Transcript creates a record of PowerShell Sessions. For documenting and archiving. The feature is very useful for administrative tasks and programming. This article describes the use of Start-Transcript and Stop-Transcript on the localhost and in remote sessions.

Simply type start-transcript and your session will be recorded in your home folder. The created text file includes the date of recording and your hostname.

Start-Transcript

Start-Transcript

Unbenannt.PNG

To specify another location and file name provide the path parameter.

Start-Transcript -Path c:\Temp\Log1.txt

Unbenannt.PNG

NoClobber

Start-Transcript overwrites files without warning. A workaround is the NoClobber parameter.

Start-Transcript -NoClobber -Path C:\Temp\Log1.txt

Unbenannt.PNG

Append

The parameter Append adds the new transcript to the end of an existing file.

Start-Transcript -Append C:\Temp\Log1.txt

Stop-Transcript

After quitting PowerShell, the recording stops. You can stop recording manually by running Stop-Transcript.

Stop-Transcript

Unbenannt.PNG

Start-Transcript on Remote Hosts

In a PowerShell remote session, you can start recording on the remote host. The file is saved on the remote computer. I am logged on Server03. I start a PowerShell Session to DC01 and run Start-Transcript. Look what happens:

Enter-PSSession -ComputerName dc01
Start-Transcript

Unbenannt.PNG

For more information about PowerShell Remote Session see my article How to configure Trusted Hosts for PowerShell Remote Sessions.

What does the file look like?

Well, the file will not win a beauty award. But all important informations and commands of your PowerShell Sesssion are saved and documented.

Unbenannt.PNG

Automatic Recording

To start recording every time when you start PowerShell, simply modify your PowerShell Profile. To create a profile type

New-Item -Path $Profile -Force

Next, add Start-Transcript to your profile.

Add-Content -Path $Profile -Value "Start-Transcript"

This will start recording automatically. Close PowerShell and open it again. You should see the following:

Unbenannt.PNG

Further thoughts

Include Start-Transcript in your PowerShell Profile: How to create PowerShell Profiles or configure logging for each module separately: Monitoring Windows PowerShell: Enable Module Logging


2 Comments

  1. […] More about Start-Transcript in my article: PowerShell: Documenting your work with Start-Transcript […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

WHOIS

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com