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

How do I effectively copy and paste input and output in the Windows PowerShell?

share|improve this question
up vote 56 down vote accepted
  • To select text in PowerShell with the mouse, just select it as usual.
  • To copy the selected text to the clipboard you have to either hit Enter, or right-click.
  • To paste into the Powershell window, right click.

keyboard

  • Paste

    alt + [space] + e + p

share|improve this answer
2  
This is what I was missing, thanks! To actually copy it is necessary to press Enter. – orschiro Mar 28 '12 at 17:13
1  
It is not necessary for me, but I have quickedit turned on in properties. – EBGreen Mar 28 '12 at 17:20
    
@orschiro: actually you don't need enter. I just tested it. You only need to highlight it and then right-click--> goes into clipboard. For pasting into powershell you only need to right click wherever you want. – kami Jan 10 '14 at 16:23
1  
ok, it works, but it won't paste multiline strings, that's BS – Alex Mills Dec 2 '14 at 5:30
1  
you can also use the menu shortcut, alt + [space] + e + p menu->edit->paste – Val Mar 5 '15 at 10:49

Depends on which PowerShell you are using. With the newer PowerGUI Script Editor or with the PowerShell ISE (integrated scripting environment) cut/paste seems to work better:

  • To cut drag the mouse across text to select, then ^C or right click to copy.
  • To paste use ^V

With the older PowerShell:

  • To cut drag the mouse across text to select, then enter to copy.
  • You can sometimes hit ^C to copy but it does not seem to ALWAYS work.
  • You can also drag to select then right click in the top window pane bar and select Edit | copy.
  • To paste right click.

Good links for people learning PowerShell::

  • The best PowerShell tutorial I've found so far is here. It goes into quite a bit of description of the command line. Sadly some of the cool stuff in the original PowerShell appears to be broken in ISE, like ctrl-home for example, to delete to start of line.

  • Some differences between these two PowerShells is here.

share|improve this answer

(Elaborating on the answer of Ƭᴇcʜιᴇ007 and Val)

Mouse

Select/Mark: Press left mouse button, drag, release.

Copy: Right-click.

Paste: With content in the clipboard, right-click.

Keyboard

Activate Mark: Alt + Space > e > k.

Select a Block: Navigate (arrow keys, Page-down, Page-up, End, Pos1) to the upper left corner of the block, press and hold Shift, navigate to the lower right corner, release Shift.

Copy: With a block selected, either hit Enter or Alt + Space > e > y.

Paste: With content in the clipboard, Alt + Space > e > p.

share|improve this answer

Powershell functions like most terminal emulators (like PuTTY) - selecting text automatically copies it to your clipboard, and right-clicking pastes the content of your keyboard at your cursor.

share|improve this answer
    
Hello Rilgon, That was my first intuition but it does not work. Nothing gets copied to the clipboard. – orschiro Mar 28 '12 at 16:55
    
That's strange, because I definitely just tried it myself just to make sure it was right, and it worked just fine. – Rilgon Arcsinh Mar 28 '12 at 16:55
    
Don't you need to hit enter to copy the contents to the clipboard in Powershell? – Bernard Chen Oct 10 '14 at 16:57

Try this from the MSDN website: Copy console screen to system clipboard . This its self is a PS script, but it copies what is currently on the window to a file.

share|improve this answer

This is just to add a partial solution for those times you don't want to use the mouse. It only helps with pasting but you can press Alt+Space then e then p. The Alt+Space opens the PowerShell window's menu, the e opens the Edit sub-menu and the p does the actual pasting. Hardly convenient but it does save you from going to the mouse.

share|improve this answer

You must log in to answer this question.

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