Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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