Problem
You want to use the PowerShell console more efficiently for copying, pasting, history management, and scrolling.
Solution
Shell console windows and make many tasks easier.
Example 18. SetConsoleProperties.ps1
PushLocation SetLocation HKCU:\Console NewItem '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe' SetLocation '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'
NewItemProperty . ColorTable00 type DWORD value 0x00562401 NewItemProperty . ColorTable07 type DWORD value 0x00f0edee NewItemProperty . FaceName type STRING value "Lucida Console" NewItemProperty . FontFamily type DWORD value 0x00000036 NewItemProperty . FontSize type DWORD value 0x000c0000 NewItemProperty . FontWeight type DWORD value 0x00000190 NewItemProperty . HistoryNoDup type DWORD value 0x00000000 NewItemProperty . QuickEdit type DWORD value 0x00000001 NewItemProperty . ScreenBufferSize type DWORD value 0x0bb80078 NewItemProperty . WindowSize type DWORD value 0x00320078 PopLocation
These commands customize the console color, font, history storage properties, QuickEdit mode, buffer size, and window size.
With these changes in place, you can also improve your productivity by learning some of the hotkeys for common tasks, as listed in Table 11. PowerShell uses the same input facilities as cmd.exe, and so brings with it all the input features that you are already familiar with—and some that you aren’t!
Table 11. Partial list of Windows PowerShell hotkeys
Hotkey
Meaning
Up arrow
Scan backward through your command history.
Down arrow
Scan forward through your command history.
PgUp
Display the first command in your command history.
PgDown
Display the last command in your command history.
Left arrow
Move cursor one character to the left on your command line.
Right arrow
Move cursor one character to the right on your command line.
Home
Move the cursor to the beginning of the command line.
End
Move the cursor to the end of the command line.
Control + Left arrow
Move the cursor one word to the left on your command line.
Control + Right arrow
Move the cursor one word to the right on your command line.
Discussion
When you launch PowerShell from the link on your Windows Start menu, it customizes several aspects of the console window:
- Foreground and background color, to make the console more visually appealing
- QuickEdit mode, to make copying and pasting with the mouse easier
- Buffer size, to make PowerShell retain the output of more commands in your console history
By default, these customizations do not apply when you run PowerShell from the Start ➝ Run dialog. The commands given in the solution section improve the experience by applying these changes to all PowerShell windows that you open.
The hotkeys do, however, apply to all PowerShell windows (and any other application that uses Windows’ cooked input mode). The most common are given in the in the solution section, but “Common Customization Points”.