PowerShell: Console Window Tips

kris_resized

If you use PowerShell on a regular or semi-regular basis you may already know these tricks of the trade, but in case you were not aware here are some neat tricks to use in the PowerShell console window.

Tab Completion

Go ahead and type a partial command and press your Tab key. PowerShell magically knows what you’re trying to look for, or at least it will venture an educated guess.

Get-Da should autocomplete to Get-Date.

Get-Date - Animated.gif

You can even press Tab (and Shift-Tab) multiple times to cycle through multiple matches.

Get- should autocomplete to multiple commands. Just keep pressing Tab to cycle forwards alphabetically and press Shift-Tab to cycle backwards alphabetically.

Get- - Expansion - Animated.gif

This is great for typing commands more quickly or for trying to type commands that you may not fully remember.

Show Recent Command List

You can show all recently typed commands at a console window by tapping the F7 key. You can then select a command by highlighting it and hitting the Enter key.

F7 - Animated.gif

Scroll Through Recent Commands

You type a command and realize you have a syntax error. Rather than type the command all over again, you can simply tap the Up arrow key to scroll backwards through your recent commands. You can tap the Down arrow key to scroll forwards.

Pause Results On Screen

Have you ever run a command that output more results than fit the screen? Usually, the results will zoom past faster than most of us can read, so we often find ourselves having to scroll to view the results.

No more!

There are two common methods for accomplishing this:

| Out-Host -Paging

| more

Something to note, however, is that it will evaluate the results of a command before outputting them to the console window.

I know that there are many other tips that each of us have come across (aliases, for example). Please feel free to add any suggestions to the comments below so that other readers may be able to benefit from your experience!