Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes I want to copy a command from Powershell to paste in a document, or I want to copy the output? How can I select and copy text in Powershell?

At least I know a way how to paste a text (or a command) into Powershell: you just right-click on Powershell.

share|improve this question

migrated from Jun 25 '11 at 10:46

This question came from our site for professional and enthusiast programmers.

You may want to move non-SharePoint related answers to the more generic Stack Overflow site. I do appreciate you are probably using PowerShell in combination with SharePoint, but this questions doesn't belong here. – Muhimbi Jun 22 '11 at 8:57
I agree. It is not a pure Sharepoint question. – mirontoli Jun 22 '11 at 11:33
up vote 34 down vote accepted

Just select the text in the console window and press enter or the right mouse button. That selected text ends up in your clipboard.

Note that this will only work if QuickEdit mode is enabled for the console window. If it is not, then either enable it in the console window properties (System menu → Properties → Options) or enter Mark mode via System menu → Edit → Mark (Alt+Space, E, K on an English Windows).

share|improve this answer
Thank you. Just what I needed. – mirontoli Jun 22 '11 at 11:31

Or send the output of your command directly to clipboard using clip.exe For example,

Get-ChildItem C:\Test -recurse | Clip
share|improve this answer
a pipe with clip i a good alternative, too! Thank you! – mirontoli Jun 22 '11 at 11:30
This will not work with Unicode, though. In that case you can use Set-Clipboard from PSCX. – Joey Jun 23 '11 at 8:00
There IS a way to have clip.exe handle Unicode correctly: set PS's $OutputEncoding variable to BOM-less UTF-16 first, as follows: $OutputEncoding = New-Object System.Text.UnicodeEncoding($false, $false) – mklement0 Mar 22 '13 at 18:57
This last trick is what I looked for coming here ! Thanks : ) – sodawillow May 18 '15 at 18:12

Have a look at Send Text in Clipboard to Application like Notepad (C# or Powershell). You will find some more tips. However, answer by @Wictor is probably the easiest solution.

share|improve this answer

I've build my own out-clipboard funciton for this.

Function Out-Clipboard{
    begin {
        $tb = New-Object System.Windows.Forms.TextBox
        $tb.Multiline = $true
        $pipeObjects = @()
    process {
    end {
            $pipeObjects | out-string -stream | %{$text = $text + $(if($text -ne $null){"`r`n"}) + $_}
            $tb.text = $text
        else {
            $tb.text = $value

Sample command line:

Get-Process | Out-Clipboard

Hope it's what you're looking for.

share|improve this answer
Your code doesn't work on my box: New-Object : Cannot find type [System.Windows.Forms.TextBox]: make sure the assembly containing this type is loaded. At line:5 char:25 + $tb = New-Object <<<< System.Windows.Forms.TextBox + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand – Winfred Jun 23 '11 at 20:55
If you check out , one of the functions provided by the community extensions is out-clipboard – Winfred Jun 23 '11 at 20:56
It is very impressive, @CosmosKey! Thanks for mentioning, @Winfred! – Anatoly Mironov Jun 26 '11 at 13:03

Go to the menubar, top left, Edit, Select All, Copy, paste in notepad

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .