Useful PowerShell keyboard shortcuts for instant script writing

PowerShell is a mighty tool that allows to speed up and automate tedious, repetitive tasks, that normally are executed via GUI (e.g. creating large numbers of users in Active Directory).

Since the tool is operated mainly by entering text commands with the keyboard, it is good to know a couple of useful shortcuts that can let you work even faster.

Below you can find a list of such key combinations.

  • Tab Automatically expands and autocompletes your command. One of the most useful keys in PS.
  • Alt+F7 Remove all commands from the history (all entered commands are preserved and accessible by tapping “up” or “down” arrow keys).
  • Up arrow key Navigate the command history back.
  • Down arrow key Navigate the command history forward.
  • Ctrl+End Removes characters to the right of the cursor.
  • Ctrl+Left arrow key Jump the cursor to the left by one word.
  • Ctrl+Right arrow key Jump the cursor to the right by one word.
  • Ctrl+C Terminate execution of the command - useful when you see that the command goes in a loop or when you just want to stop its operation before it finishes.
  • Ctrl+S Pause/resume displaying of the command’s output.

  • F1 Insert your last command one character at a time.
  • F2 Insert your last command up to the character you type in the prompt window.
  • F3 Insert your last command at the end of your currently entered command.
  • F4 Delete everything in your command between the current cursor position and the character you type.
  • F5 Navigate the command history back (same as with “up” arrow key).
  • F7 Shows your command history list, which you can navigate with “up” and “down” arrow keys. To run selected command - hit “Enter”. To paste it into console - hit the “right” arrow key.
  • F8 Use this key after entering a text in the console - tapping F8 will search your command history for matches.

These are just a couple of a number of available keys and shortcuts. More you work with the PS console more useful they become - nothing beats the feeling when a complicated script is created with just a couple of keystrokes.

Łukasz is a software developer and owner of MSH Software company which builds email processing tools for Microsoft Exchange, Zimbra Collaboration Suite and Postfix. He specializes in server, desktop and web applications written in Java, .NET and C++.