Copying Command History to Clipboard

by Jul 11, 2012

Here's a one-liner that copies all commands from your command history to the clipboard. From there, you could paste them into your favorite PowerShell editor and make your interactive code a script:

PS> Get-History | Select-Object -ExpandProperty CommandLine | clip

Note that clip.exe is supported on Windows 7 and above only.

Twitter This Tip! ReTweet this Tip!