Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Windows PowerShell Shortcut Keys

News

Windows Powershell

Recommended Books Recommended Links Windows PowerShell Shortcut Keys Windows Powershell oneliners

Unixification

Windows XP Slow Startup and Shutdown

Like all good command shells, Windows PowerShell includes a number of shortcut keys that can lessen the amount of typing needed to get you through a Windows PowerShell session. (Actually, as far as we know even bad command shells include shortcuts keys.) This document briefly describes the most commonly-used PowerShell shortcut keys. Because most of these shortcut keys are meaningless without a command history, we’ll assume our PowerShell session has been up and running long enough for us to have issued the following set of commands:

1. cd c:\scripts
2. get-childitem -recurse
3. get-executionpolicy
4. set-executionpolicy Unrestricted
5. get-process
6. get-process -name "Notepad"
7. get-history
8. cd c:\windows
9. get-childitem *.dll
10. clear-host

And now let’s take a look at the shortcut keys and what they’re used for.

  1. Up Arrow

    Moves backward through the command history, beginning with the last command typed and working back towards the first command typed.

    For example, if the last command you typed was clear-host (as in our sample command history) then pressing the Up arrow key one time will display clear-host at the command prompt; you can then run this command by pressing ENTER. Pressing the Up arrow key a second time will display the command get-childitem *.dll. Pressing the key a third time displays cd c:\windows, and so on.

  2. Down Arrow

    Moves forward through the command history. Continuing with the Up arrow example, suppose you backed your way through the command history (starting with the latest command and moving backwards towards the first command) until get-process –name “Notepad” was displayed at the command prompt. If you now press the Down arrow key you’ll move forward through the command history and get-history will be displayed. Press the Down arrow key a second time and cd c:\windows will be displayed.

  3. PgUp

    Displays the first command in the command history. In our example, that causes cd c:\scripts to be displayed at the command prompt.

  4. PgDn

    Displays the last command in the command history. In our example, that’s the clear-host command.

  5. Left Arrow

    Moves the cursor one character to the left on the command line. For example, if the cursor is under the\ in command cd c:\scripts, pressing the Left arrow key will move the cursor under the :.

  6. Right Arrow

    Moves the cursor one character to the right on the command line. For example, if the cursor is under the : in cd c:\scripts, pressing the Right arrow key will move the cursor under the \.

  7. Home

    Moves the cursor to the beginning of the command line.

  8. End

    Moves the cursor to the end of the command line.

  9. Control + Left Arrow

    Moves the cursor one “word” to the left on the command line. For example, suppose the command line is displaying the command get-process –name “Notepad”; in addition, suppose that the cursor is under any of the characters in the “word” get-process. (In this case, “words” are strings of characters delineated by blank spaces.) Holding down the Ctrl key and pressing the Left arrow key will cause the cursor to move beneath the g in get-process.

  10. Control + Right Arrow

    Move the cursor one “word” to the right on the command line. For example, suppose the command line is displaying the command get-process –name “Notepad”; in addition, suppose that the cursor is under any of the characters in the “word” –name. (In this case, “words” are strings of characters delineated by blank spaces.) Holding down the Ctrl key and pressing the Right arrow key will cause the cursor to move beneath the in “Notepad”.

  11. Control + c

    Cancels the current command. If you are partway through typing a command and then press Ctrl+c Windows PowerShell will ignore everything you’ve typed on the line and present you with a new “blank” command line.

  12. F2

    Creates a new command line from the partial contents of your last command line. For example, suppose your previous command was get-process –name “Notepad”. If you press F2, PowerShell will respond with the following request:

    GRAPHIC – Enter char to copy up to:

    If you type (representing the first quotation mark) PowerShell will insert the text from your previous command, up to (but not including) the double quote mark:

    get-process –name
    

    Note that PowerShell will always go the first instance of a character. If you type an e in the dialog box PowerShell will begin “typing” until it encounters the first e in get-process. Therefore, all that will be displayed on your screen is the following:

    g
    

    To cancel when asked to enter a character, press Enter without entering anything.

  13. F3

    Displays your previous command. This is equivalent to pressing the Up arrow key once. However, while you can press Up arrow multiple times to continue cycling through your command history, pressing F3 additional times has no effect: only your last command will be displayed.

  14. F4

    Beginning from the current cursor position, F4 deletes characters up to the specified character. For example, suppose the command get-process –name “Notepad” is displayed, and the cursor is beneath the c in process. If you press F4, the following dialog box appears:

    GRAPHIC: Enter char to delete up to:

    If you press PowerShell will begin deleting characters from the command prompt and continue deleting characters until it encounters a character. In this case, that means the following (nonsensical) command will be displayed:

    get-pro-name "Notepad"
    

    If you enter a character (say, z) which does not appear in the command string then all the remaining characters in the string will be deleted:

    get-pro
    

    This also occurs if you simply press ENTER when the dialog box appears.

    To cancel this operation, press Ctrl+Z.

  15. F5

    Like the Up arrow key, F5 moves you backward through the command history.

  16. F7

    Displays a “dialog box” that allows you to select a command from your command history:

    GRAPHIC: history

    Scroll through the dialog box using the Up and Down arrow keys; when you find a command you want to execute press ENTER. Alternatively, locate the desired command and then press the right arrow key; that will “type” the command at the command prompt but will not execute that command. To then execute the command, you must press ENTER.

    To dismiss the dialog box without selecting a command, press Escape.

  17. F8

    Moves backwards through the command history, but only displays commands matching text you type at the command prompt. For example, suppose you type set and then press F8. In that case (and using our sample command history) PowerShell will only display the command set-executionpolicy. Why? Because that’s the only command in the history that matches the string set.

    Now, type cd and press F8. This time around, PowerShell will display the command cd c:\windows. Press F8 a second time and the command cd c:\scripts will be displayed. That’s because, in this case, we have two commands that match the string cd.

  18. F9

    Enables you to run a specific command from the command history. When you press F9 PowerShell prompts you to enter a command number, corresponding to the numbers displayed in the history “dialog box” (see F7):

    GRAPHIC: Enter command number:

    To run a command, type the appropriate number and press ENTER. Using our sample history, typing 5 and pressing ENTER runs the command get-process.

    To cancel this operation, press Escape.

 


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Mar 23, 2011] The Great Dollar Dollar - Windows PowerShell Blog - Site Home - MSDN Blogs

$$
Contains the last token in the last line received by the session.

(…)

The '$$' ("dollar dollar") automatic variable always holds the last thing on the last line you typed. Now, why would you ever care about tokens received by the session? It saves you typing, that's why!

PS>notepad $$

Voila – notepad opens 'c:\windows\system32\drivers\etc\hosts'.

If you're a shell polyglot, the Bash shell (in Unix, Mac, etc.) supports something similar through its '!$' word designator.



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019