Two of the most important keyboard shortcuts in any PowerShell environment – whether console, ISE, or VSCode – are TAB and CTRL+SPACE.

TAB triggers autocompletion, and as a rule of thumb, you should use this after typing at least 3 characters of a command or parameter name. Press TAB multiple times until autocompletion suggests what you were intending to type. Should autocomplete not work, make sure there is no typo in the text you already typed.

CTRL+SPACE is even more useful. In editors such as ISE and VSCode it opens graphical IntelliSense-like menus, yet in the console it also displays all available choices in a list.

Even though editors like ISE and VSCode typically open IntelliSense-like menus automatically on certain trigger keys such as “.” and “-“, you can use CTRL+SPACE to re-open an IntelliSense menu that was accidentally closed. Plus often, when you manually press CTRL+SPACE, you will manage to open helpful IntelliSense menus that did not open automatically after all.

If you are in doubt what to enter next, and there is no IntelliSense-like menu open already, next time try pressing CTRL+SPACE manually. Try this:

Get-Service | Where-Object

After adding a space in ISE or VSCode, now press CTRL+SPACE, and automagically a menu offers the service properties that you can use to filter the data. IntelliSense did not open automatically in scenarios like this because there is no trigger key that was pressed before.




Twitter This Tip! ReTweet this Tip!

Anonymous
  • Anyway to make this work on the Mac? Whether on the command-line or VS Code integrated console it doesn't have the same auto-completion behavior and Ctrl+Space doesn't work. The best you get is pressing Tab twice after a hyphen will display the parameter list below the command line. That's helpful, but not nearly as nice as you experience with Windows.