Logging your every move with a PowerShell transcript

There are a few methods for creating a PowerShell transcript that logs everything. We highlight a few of these and what to know about each.

How can I make a PowerShell transcript log everything I do?

Admins can create PowerShell transcripts to log everything they do. The PowerShell Console host -- the blue window launched from the Windows Start menu or Start screen -- supports the creation of transcripts. Just run Start-Transcript and provide a filename, and everything you run in that window will be captured, including command output. Transcripts are per-runspace, which means that each new PowerShell window will have to have its own transcript. Close the window or run Stop-Transcript to close the file.

Any runspace that uses the Console window can use a transcript, and that includes the Exchange Management Shell, SharePoint Management Shell and whatever other "management shell" shortcuts you've got. Those all run PowerShell.exe -- the Console host -- and have pre-loaded scripts and add-ins.

By contrast, the PowerShell Integrated Scripting Environment (ISE) does not support transcripts. Other hosting applications (think commercial script editors) may not either. With those hosting applications, they need to provide their own logging mechanism since the ISE has none; otherwise, you're out of luck.

If you get into Remoting, the rules get a bit odd.

When you interactively remote into a machine using Enter-PSSession, the remote machine cannot keep a transcript or a PowerShell transcript. That's because the hosting application on the remote machine doesn't do transcripts. But your machine can keep a transcript of whatever commands you send to the remote machine and the output that comes back. With remoting, you're not really using a SecureShell (SSH) type of connection. You're still typing on your local console; complete commands are sent to the remote machine for execution and results are deserialized into your local console.

About the author
Don Jones is a well-known and respected PowerShell expert and educator. He's co-author of three books on PowerShell (see PowerShellBooks.com for a list). You can find his content online, including his PowerShell Q&A forums, by visiting DonJones.com.

Dig Deeper on Microsoft cloud computing and hybrid services

Cloud Computing
Enterprise Desktop
Virtual Desktop