

Quick Tip - Re-Run The Last Command
source link: https://thomasrayner.ca/quick-tip-re-run-the-last-command/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Quick Tip - Re-Run The Last Command
Sometimes, while you’re poking around in the console, you want to re-run the last command. Sure, you can hit the up arrow and enter, but PowerShell always gives you multiple ways to do things.
It’s easy, using the Invoke-History cmdlet. You can also use its alias which is just r. Running that cmdlet without any parameters will run the last command from the console. Alternatively, you can specify a value for the ID parameter, and run one from further back in your history.
How do you find out what those IDs should be? Using Get-History to see everything you’ve run in this session, and the ID number for that command.
Recommend
-
21
Quick Tip: Simulate a bad network connection on macOS (and Linux)2020-06-19Yesterday, I got a tip from a colleague to fake a poor network connection (for debugging an issue) with tc (
-
10
Quick Tip: GitHub Action for pushing docker images2020-06-16Here is a full example of using the official Docker build-push-action for GitHub to publish directly to th...
-
14
Quick Tip - See All The Tab-Completion Options At Once In The PowerShell Console If you’re used to working in VS Code or the PowerShell ISE, you’ve undoubtedly enjoyed intellisense which is the feature that shows you all...
-
20
Quick Tip - Split A PowerShell Collection Into Two Arrays Did you know that you can use Where-Object to split a collection into two arrays? Like, if you had an array containing the numbers 1 to 10, you c...
-
7
Quick Tip - PowerShell Supports Partial Parameter Names Did you know that PowerShell supports the usage of partial parameter names? This isn’t such a big deal since tab completion is a thing… and if you’re writing code,...
-
16
Quick Tip - Update a Tag on an Azure Resource Working with Azure resources can be a bit of an adventure sometimes. Say you want to update a tag on an Azure resource. Not remove it, but change its value. If you try to add...
-
10
Quick Tip - Did the last command work or not? In PowerShell, there is usually at least a few ways to do most tasks and detecting if the last command resulted in an error or if it worked is no exception. You could wrap co...
-
12
Quick Tip - Copy The Output Of The Last PowerShell Command To Clipboard I recently found myself poking around in PowerShell and going “oh, good now I want to copy and paste that output into an email/dialog box/tweet/note...
-
9
Quick Tip - String Manipulation - First Name Last Name to Last Name, First Name I’ve got kind of a silly post this week. I often get a list of names in the format… John Doe Jane Doe Mik...
-
12
Quick Tip - Run An SMA Runbook At A Specific Date/Time Happy New Year’s Eve! Here’s a quick tip just before New Year’s. I recently answered
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK