Want to keep track of your PowerShell commands effortlessly? This article reveals a simple way to copy your command history to the clipboard, making it easy to save and reuse your scripts. Plus, learn how to filter commands from the last 15 minutes, helping you focus on recent tasks. Discover how this handy tip can streamline your workflow and enhance your productivity in PowerShell!
Harvest your command history for a streamlined workflow
If you played interactively with PowerShell and then discovered that youd like to keep the code that you just executed, here is a useful line:
(Get-History).CommandLine | Set-ClipBoard
It copies your entire command line history to the clipboard so you can easily paste it to your favorite editor and save it.
If your history is very large, you can add time filtering. This will get you just the commands from the past 15 minutes:
(Get-History | Where-Object StartExecutionTime -gt (Get-Date).AddMinutes(-15)).CommandLine | Set-ClipBoard
Your ultimate PowerShell Cheat Sheet
Unleash the full potential of PowerShell with our handy poster. Whether you're a beginner or a seasoned pro, this cheat sheet is designed to be your go-to resource for the most important and commonly used cmdlets.The poster is available for download and in paper form.
Related links
- ScriptRunner ActionPacks will help you automate tasks
- Try out ScriptRunner here
- ScriptRunner: Book a demo with our product experts