Powershell, The Clipboard, and re-living the past …

One of my favorite Powershell features is the ability to export the output of pretty much anything to the clipboard using | clip

I've found that piping to clip is much easier than trying to export output to a TXT or CSV file, then finding and opening the file…

For those of you who are experimenting with pipelining so you can perform basic (or somewhat complex) tasks it can also help to save that winning combination of commands without needing to right-click, mark (which invariably winds up returning the command prompt as well) several lines, copy, paste to the clipboard, remove carriage returns etc… just to get the line into a re-usable format you can save in OneNote, Outlook, Notepad or whatever.

Instead, once you've got the winning command, do the following :



Locate the ID # that matches the command you want to save

(Get-History -ID 7).CommandLine | Clip

Replace the # 7 with the line from your command history you want to save. 


The winning command is now in your clipboard, go forth and paste …

Reader Comments

Comments are closed.