Log everything typed and returned in PowerShell

Log everything typed and returned in PowerShell

Q. How can I log everything typed and returned in a PowerShell session?

A. PowerShell version 4 and above has a transcript capability that logs information about the session, commands typed and the results. This can be started with:

$trans = start-transcript

and stopped with stop-transcript.

This can be enabled for all scripts via Group Policy:

  1. Open the policy you wish to use to apply
  2. Navigate to Computer Configuration - Administrative Templates - Windows Components - Windows PowerShell
  3. Double click Turn on PowerShell Transcription
  4. Set to Enabled and by default scripts will be saved to users Documents folders or a central folder can be specified where all transcripts will be saved to (make sure you secure this folder so users cannot see other users transcripts)
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish