June 1, 2009

Transcript Log in Powershell

How many times have you typed up a script and then by accident closed the command prompt. I can tell you it has happened to me a few times! Sure, I can probably whip it up again in a few minutes, but it is annoying! Well, here is something that I came across:
Start-Transcript D:\tmp\Transcript.txt

# Do some work
get-wmiobject win32_computersystem

This will create a log called Transcript.txt that contains everything you did with powershell for that session. If you like, you can have it start up each time by setting this in your environment on powershell startup.

There are a few things to note with this:
  • This will write over any previous sessions unless you set it up to append by using -Append $true in your Start-Transcript
  • This works only in the command line and not in the ISE. I guess this was missed?
  • This will log everything you type within the session

No comments:

Post a Comment