Copy PowerShell command into clipboard

Sometime I want to post my PowerShell commands into blog.
I don’t like default host with stupid rectangular selection.

So the workaround I am using is

(Get-History)[-1].CommandLine | clip

It will copy last command you typed into Clipboard


About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to Copy PowerShell command into clipboard

  1. Thanks for that. Going off your example, you could shorten it to (h)[-1].CommandLine.

    Thanks again!

  2. Pingback: Powershell command line clipboard | The Things I do

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s