Skip to content

Instantly share code, notes, and snippets.

@diecknet
Created July 6, 2021 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diecknet/e2a9390f7cb1e4bbe8479d9c85dcd827 to your computer and use it in GitHub Desktop.
Save diecknet/e2a9390f7cb1e4bbe8479d9c85dcd827 to your computer and use it in GitHub Desktop.
Copy last PowerShell command into clipboard
<#
I initially used this code:
history | Select-Object -Last 1 -ExpandProperty CommandLine | clip
But recently found this shorter version at https://powershellmagazine.com/post/2012-11-06-pstip-send-the-last-command-executed-to-clipboard/
#>
(Get-History)[-1].commandline | clip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment