Monthly Archives: November 2008

Easy Script Logs With Transcripts #PowerShell

Tags :

Category : Windows PowerShell

It is a common requirement to implement some logging into scripts. Imagine the scripted processesing of hundreds of items like user directories or whatever. If you later need to investigate the facts that led to issues a log file of that script could help to identify the cause of the problem.

PowerShell has a built-in recording feature which can be turned on and off with the cmdlets Start-Transcript and Stop-Transcript. When in script mode, Start-Transcript records all output that appears on the console in a text file as long as recording is stopped with Stop-Transcript.

As Start-Transcript creates a record of a PowerShell session in a text file it can be considered as a tee command that is working in the background. Once turned on all the console output will automatically recorded in the transcript file.

If your script is already designed to display information, warning, errors, etc. on the console you only need to turn on/off the recording in a text file as follows: