#PSTip Capture console screen

Note: This tip requires PowerShell 2.0 or above.

PowerShell has many logging capabilities but sometimes what you want is to capture what’s already written to the console. Capturing this information can be a challenge as you need to script the console buffer content. You can see how in this post by the PowerShell team blog. In the ISE however this task becomes a lot easier; it is just a matter of reading the content of the output (console) pane.

In ISE v2:

PS> $psise.CurrentPowerShellTab.Output.Text

In ISE v3:

PS> $psise.CurrentPowerShellTab.ConsolePane.Text

About the author: Shay Levy

Shay Levy is a Co-founder and editor of the PowerShell Magazine. He is a multiple-year recipient of the Microsoft MVP award, and a Microsoft Certified Trainer (MCT). Shay often covers PowerShell related topics on his blog and you can also follow him on Twitter at @ShayLevy

Related Posts

%d bloggers like this: