PowerShell Shortcuts

Unix Shells have many shortcuts that make life easier when using the shell. What people often forget is that de good old Command Prompt also had shortcuts. HowToGeek wrote a good article about it at https://www.howtogeek.com/254401/34-useful-keyboard-shortcuts-for-the-windows-command-prompt/.

Recent versions of PowerShell also have even more powerful keyboard shortcuts. This are implemented by the PSReadLine Module. This module is included with PowerShell 5 and higher. The documentation can be found here: https://docs.microsoft.com/en-us/powershell/module/psreadline/?view=powershell-5.1.

When you are working in PowerShell and forgot which short cutes are available. Then you have two options. The first one is to go to the documentation, see the link above. Or you can type <Ctrl+Alt+?>. You will then get the full list of shortcuts. The list you see in the image below is only halve of the keyboard shortcuts. See for yourself in your own PowerShell Window.

You probably have been using some of these shortcuts without knowing it. Like the <UpArrow> and <DownArrow> keys to scroll thought the history. But did you know there are als keyboard shortcuts to search in the history? 
These are <Ctrl+r> and <Ctrl+s>. With the first one you can search backwards in your history. And with the second one you can search forward in your history. The screen will show if you do a backward for forward search.

To search backward in your history you first press <Ctrl+r> and then type part of the command or parameter you want to search for. The first result will be shown. Press <Ctrl+r> to scroll through the results. Press <Enter> to select the result and the press <Enter> again to execute the command. Forward search <Ctrl-s> works in the same way. 

Another useful shortcut is <Ctrl+SpaceBar>, this is like <Tab> on steroids. We have all used <Tab> to complete commands. But finding the right command can take some time. There are for example 16 commands that start with Get-NetIP. Instead of pressing <Tab> many times until you find the right one. You can also press <Ctrl+SpaceBar> and then get a nice menu with all the possible commands. You can then select the command you want with the <Arrow> keys and the press <SpaceBar> to use the command. To execute the command immediately just press <Enter>.

The shortcut <Ctrl+SpaceBar> not only works for command, but also for parameters and parameter values.

As you can see using shortcuts can make your life in PowerShell more easier and efficient. Give it a try.