Windows 10 powershell горячие клавиши

PowerShell scripts take a little setting up if you want them to run automatically at a given time. It takes more than using just a scheduled task as the script won’t run in PowerShell as an action. If you’re not looking to automatically run these scripts and instead are looking to run PowerShell scripts with keyboard shortcuts, you can do just that. There are some limitations to this process but nothing that makes the process tedious to use.

The first thing you need is the PowerShell script. Go ahead and create it. Move it somewhere you know you won’t delete it by accident. Once you’ve done that, go to your desktop and right-click on an empty area. From the context menu, select New>Shortcut.

In the location field, enter the following and make sure you replace “path-to-script” with the complete path to the PowerShell script you want to run with a keyboard shortcut.

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "path-to-script"

Example

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "C:\Users\fatiw\Desktop\toastNotification.ps1"

Click Next, and enter a name for the shortcut. If you want, you can also change the icon that the shortcut uses. By default, it will use the PowerShell icon.

After you’ve created the shortcut, right-click it and select Properties from the context menu. Go to the Shortcut tab, click inside the ‘Shortcut key’ field, and record the keyboard shortcut that you want to use to run the app.

You only need to enter a letter or number. The Ctrl+Alt keys are added by default and will be part of all keyboard shortcuts for running apps/shortcuts to apps.

That should do the trick. You can now run the script with the shortcut that you recorded.

Limitations

I mentioned earlier that this method has limitations, though they’re not very restricting. The limitation is that the shortcut, the one you created, must be placed on the desktop or added to the Start Menu. If you move the shortcut anywhere else, e.g., to a different drive on your PC, or nest it inside a folder, the keyboard shortcut will not be able to run the script.

Keeping the script on your desktop is really the most reliable way to run scripts with a keyboard shortcut. It seems that using the Pin to Start option in the shortcut’s menu doesn’t really do the trick and neither does adding it to the Start Menu folder. It may have to do with the script I tested this out on so go ahead and try it out for yourself. If adding the shortcut to the Start Menu won’t work, you’re going to have to place it on your desktop.

default avatar image

Fatima Wahab

Fatima has been writing for AddictiveTips for six years. She began as a junior writer and has been working as the Editor in Chief since 2014.

Fatima gets an adrenaline rush from figuring out how technology works, and how to manipulate it. A well-designed app, something that solves a common everyday problem and looks

86992Accept the input or move to the next line if input is missing closing token.entern/APowershellEditing86993Move cursor to the next line without attempting to execute the inputshift+entern/APowershellEditing86994Delete the character before the cursorbackspacen/APowershellEditing86995Delete the character before the cursorctrl+hn/APowershellEditing86996Delete text from the cursor to the start of the linectrl+homen/APowershellEditing86997Delete previous wordctrl+backspacen/APowershellEditing86998Cancel editing the linectrl+cn/APowershellEditing86999Copy selected textctrl+cn/APowershellEditing87000Delete selected region placing deleted text in the system clipboardctrl+xn/APowershellEditing87001Delete the character under the cursordeln/APowershellEditing87002Delete text from the cursor to the end of the linectrl+endn/APowershellEditing87003Inserts a new empty line above without executingctrl+entern/APowershellEditing87004Inserts a new empty line below without executingctrl+shift+entern/APowershellEditing87005Delete next wordctrl+deln/APowershellEditing87006Paste text from the system clipboardctrl+vn/APowershellEditing87007Paste text from the system clipboardshift+insn/APowershellEditing87008Redo an undoctrl+yn/APowershellEditing87009Undo all editsescn/APowershellEditing87010Undo a previous editctrl+zn/APowershellEditing87011Copy the text of the last argument to the inputalt+.n/APowershellEditing87012Move the cursor back one characterleftn/APowershellCursor87013Move the cursor to the beginning of the current or previous wordctrl+leftn/APowershellCursor87014Move the cursor to the beginning of the linehomen/APowershellCursor87015Move the cursor to the end of the lineendn/APowershellCursor87016Move the cursor forward one characterrightn/APowershellCursor87017Go to matching bracectrl+]n/APowershellCursor87018Move the cursor forward to the start of the next wordctrl+rightn/APowershellCursor87019Remove all items from command line (not PowerShell) historyalt+f7n/APowershellHistory87020Search history forward interactivelyctrl+sn/APowershellHistory87021Search for the previous item in the history that starts with the current inputf8n/APowershellHistory87022Search for the next item in the history that starts with the current inputshift+f8n/APowershellHistory87023Replace the input with the next item in the historydownn/APowershellHistory87024Replace the input with the previous item in the historyupn/APowershellHistory87025Search history backwards interactivelyctrl+rn/APowershellHistory87026Complete input if there is a single completion, otherwise select completionctrl+spacen/APowershellCompletion87027Complete the input using the next completiontabn/APowershellCompletion87028Complete the input using the previous completionshift+tabn/APowershellCompletion87029Clear the screen and redraw the current line at the top of the screenctrl+ln/APowershellMiscellaneous87030Start or accumulate a numeric argument to other functionsalt+0 or alt+1 or alt+2 or alt+3 or alt+4 or alt+5 or alt+6 or alt+7 or alt+8 or alt+9 or alt+-n/APowershellMiscellaneous87031Scroll the display down one screenpagedownn/APowershellMiscellaneous87032Scroll the display down one linectrl+pagedownn/APowershellMiscellaneous87033Scroll the display up one screenpageupn/APowershellMiscellaneous87034Scroll the display up one linectrl+pageupn/APowershellMiscellaneous87035Show all key bindingsctrl+alt+?n/APowershellMiscellaneous87036Show the key binding for the next chord enteredalt+?n/APowershellMiscellaneous87037Select the entire line. Moves the cursor to the end of the linectrl+an/APowershellSelection87038Adjust the current selection to include the previous charactershift+leftn/APowershellSelection87039Adjust the current selection to include from the cursor to the end of the lineshift+homen/APowershellSelection87040Adjust the current selection to include the previous wordctrl+shift+leftn/APowershellSelection87041Adjust the current selection to include the next charactershift+rightn/APowershellSelection87042Adjust the current selection to include from the cursor to the start of the lineshift+endn/APowershellSelection87043Adjust the current selection to include the next wordctrl+shift+rightn/APowershellSelection87044Read a character and move cursor to the next occurence of that characterf3n/APowershellSearch87045Read a character and move cursor to previous occurence of that charactershift+f3n/APowershellSearch

F1
Editing text
(Script pane) Help. Important: You can specify that F1 help comes from the TechNet Library on the web or downloaded Help (see Update-Help). To select, click Tools, Options, then on the General Settingstab, set or clear Use local help content instead of online
Ctrl + C
Editing text
(Script pane, Command Pane, Output Pane) Copy
Ctrl + X
Editing text
(Script pane) Cut
Ctrl + M
Editing text
(Script pane) Expand or Collapse Outlining
Ctrl + F
Editing text
(Script pane) Find in Script
F3
Editing text
(Script pane) Find Next in Script
↑   Shift + F3
Editing text
(Script pane) Find Previous in Script
Ctrl + ]
Editing text
(Script pane) Find Matching Brace
Ctrl + V
Editing text
(Script pane, Command Pane) Paste
Ctrl + Y
Editing text
(Script pane, Command Pane) Redo
Ctrl + H
Editing text
(Script pane) Replace in Script
Ctrl + S
Editing text
(Script pane) Save
Ctrl + A
Editing text
(Script pane, Command Pane, Output Pane) Select All
Ctrl + J
Editing text
(Script pane, Command Pane) Show Snippets
Ctrl + Z
Editing text
(Script pane, Command Pane) Undo
Ctrl + N
Running scripts
New
Ctrl + O
Running scripts
Open
F5
Script debugging
Run/Continue
F8
Running scripts
Run Selection
Ctrl + Break
Running scripts
Stop Execution. Ctrl + C can be used when the context is unambiguous (when there is no text selected).
Ctrl + ⭾ Tab
Windows PowerShell tabs
Next Windows PowerShell tab. This shortcut works only when no files are open on any Windows PowerShell tab
Ctrl + ↑   Shift + ⭾ Tab
Windows PowerShell tabs
Previous PowerShell tab. This shortcut works only when no files are open on any Windows PowerShell tab
Ctrl + D
Customizing the view
Go to Command (v2) or Console (v3 and later) Pane
Ctrl + ↑   Shift + O
Customizing the view
Go to Output Pane (v2 only)
Ctrl + I
Customizing the view
Go to Script Pane
Ctrl + R
Customizing the view
Hide Script Pane
Ctrl + 1
Customizing the view
Move Script Pane Up
Ctrl + 2
Customizing the view
Move Script Pane Right
Ctrl + 3
Customizing the view
Maximize Script Pane
Ctrl + +
Customizing the view
Zoom In
Ctrl + -
Customizing the view
Zoom Out
F11
Script debugging
Step Into
F10
Script debugging
Step Over
↑   Shift + F11
Script debugging
Step Out
Ctrl + ↑   Shift + D
Script debugging
Display Call Stack
Ctrl + ↑   Shift + L
Script debugging
List Breakpoints
F9
Script debugging
Toggle Breakpoint
Ctrl + ↑   Shift + F9
Script debugging
Remove All Breakpoints
↑   Shift + F5
Script debugging
Stop Debugger
C
Script debugging
Continue
S
Script debugging
Step Into
V
Script debugging
Step Over
O
Script debugging
Step Out
⤶ Enter
Script debugging
Repeat Last Command (for Step Into or Step Over)
K
Script debugging
Display Call Stack
Q
Script debugging
Stop Debugging
L
Script debugging
List the Script
H
Script debugging
Display Console Debugging Commands
?
Script debugging
Display Console Debugging Commands
Ctrl + W
Windows PowerShell tabs
Close PowerShell Tab
Ctrl + T
Windows PowerShell tabs
New PowerShell Tab
Alt + F4
Starting and exiting
Exit
Ctrl + ↑   Shift + P
Starting and exiting
Start PowerShell.exe (Windows Powershell console)

PowerShell shortcuts streamline your command-line experience by allowing you to execute common tasks efficiently with concise commands.

Here’s a simple example of a PowerShell shortcut that retrieves the current directory:

Get-Location

Understanding the PowerShell Command Line Interface

PowerShell has grown to encompass a robust command line interface promoting automation and simplified management of tasks in Windows environments. To get started, it’s crucial to understand the environments available, notably the PowerShell console, Integrated Scripting Environment (ISE), and third-party editors like Visual Studio Code.

PowerShell Console vs ISE and VSCode
While the PowerShell console focuses on command execution, ISE provides a more visual approach with features like syntax highlighting and integrated debugging tools. Visual Studio Code, on the other hand, extends beyond PowerShell with significant plugins that enhance coding experience with IntelliSense and Git integration.

Basic Navigational Shortcuts

Mastering basic navigational shortcuts significantly improves efficiency when interacting with PowerShell.

Using Tab for Autocomplete
One of the most valuable shortcuts is the use of the Tab key, which allows users to autocomplete commands. For instance, typing `Get-` and hitting Tab will toggle through available cmdlets that start with those letters, saving crucial time and reducing typographical errors.

Using the Up and Down Arrow Keys
Navigating through your command history with the Up and Down arrow keys will enable you to quickly access previous commands. This feature becomes particularly useful during extensive scripting sessions where retyping commands can become redundant.

Clear-Host Command
At times, your console may become cluttered with output. The `Clear-Host` command can be employed to quickly clean the console for improved readability. Simply type:

Clear-Host

Executing this command provides a fresh workspace, which is especially helpful when working with numerous commands and outputs.

Essential Keyboard Shortcuts in PowerShell

Keyboard shortcuts streamline command editing and console navigation.

Editing and Navigation Shortcuts
Utilizing the Home and End buttons enables quick movement to the start or end of a command line, creating a smoother workflow when editing or correcting commands.

Ctrl + A: Select All
The shortcut Ctrl + A allows users to select all text in the console. This is particularly useful for copying code snippets or outputs that you want to manipulate further.

Ctrl + C/Ctrl + V: Copy/Paste
In most contexts, copying and pasting text before executing commands is straightforward. However, PowerShell emphasizes using Ctrl + Shift + C to copy and Ctrl + Shift + V to paste. This differentiation prevents conflicting with the default behavior of these shortcuts in other applications.

Ctrl + Up/Down Arrow
Scrolling through previous output with Ctrl + Up/Down Arrow will enable quicker analysis of results without the need to rerun commands.

Frequently Used PowerShell Cmdlets

Alias Overview
In PowerShell, an alias is a shorthand reference to a cmdlet or function, effectively reducing the typing burden on users. Through the use of aliases, users can navigate and execute commands more fluidly.

Commonly Known Aliases
PowerShell comes with many predefined aliases, enhancing command expediency. For example:

  • `ls` for `Get-ChildItem`
    Typing `ls C:\` will display the contents of the C drive, much like using the traditional `dir` command in CMD.

  • `cp` for `Copy-Item`
    To copy a file quickly, using `cp file.txt C:\Backup\` allows for a straightforward transfer without the verbose syntax.

Creating Your Own Aliases
Crafting personalized aliases can further optimize your workflow. You can use the following code to create a simple alias:

Set-Alias -Name gs -Value Get-Service

This allows you to type `gs` instead of the full command, making repeated calls to check service status much quicker. You can ensure these aliases persist across sessions by adding them to a PowerShell profile.

Shortcuts for Command Execution

Piping and Redirection Shortcuts
PowerShell leverages powerful piping functionality allowing the output of one command to be passed as input to another. The pipe (`|`) is instrumental in building efficient one-liners. For example, you can filter for CPU-intensive processes as follows:

Get-Process | Where-Object { $_.CPU -gt 100 }

Output redirection is another fundamental command. By using the `>` operator, you can dump the results of a command into a file:

Get-Process > Processes.txt

Utilizing `>>` allows appending results to an existing file, preserving previous information.

Best Practices for Efficient Scripting

Script Optimization Techniques
Creating functions for repetitive tasks can elevate your scripting capabilities. For instance, the following simple function helps to retrieve the latest file in a directory:

function Get-LatestFile {
    param([string]$path)
    Get-ChildItem $path | Sort-Object LastWriteTime -Descending | Select-Object -First 1
}

This function optimizes repeated actions and makes scripts cleaner and more maintainable.

Using Parameters for Flexibility
Incorporating parameters allows you to customize the function further. For example, you can extend `Get-LatestFile` to accept file types or limits on the number of files returned, making it a robust utility.

Utilizing Integrated Scripts with Shortcuts
Combining the use of shortcuts and functions can lead to highly efficient scripting practices, minimizing redundancy and enhancing maintainability.

Common Mistakes and How to Avoid Them

Mistakes Beginners Make
Often, beginners neglect the importance of thorough documentation, leading to confusion in complex scripts. Additionally, a reliance on memorization of commands can hinder learning.

Best Practices to Mitigate Errors
To avoid these pitfalls, it’s highly recommended to frequently refer to official PowerShell documentation and surrounding community support. Testing and breaking down scripts can expose errors early, leading to more successful automation efforts.

Conclusion

Enhancing your workflow with PowerShell shortcuts can transform your command line interactions into a streamlined, efficient experience. Your ability to leverage autocomplete features, keyboard shortcuts, and commands will improve your productivity significantly. Regular practice and exploration of advanced commands and scripting techniques will yield greater results and deeper comprehension of the PowerShell environment.

Additional Resources

For those looking to deepen their knowledge, several resources can be invaluable. Explore the official PowerShell documentation for comprehensive cmdlet listings and advanced functionalities. Engaging with the PowerShell community and forums can provide additional insights, troubleshooting advice, and support during your learning journey. Consider online courses to gain structured knowledge and hands-on practice for mastery of PowerShell.

Command Prompt and PowerShell are two essential tools for a command-line user on Windows PCs. If you access these tools frequently, you can add the Command Prompt and PowerShell shortcuts to your desktop to quickly access them.

You can even assign a keyboard shortcut to these apps.

Create a Command Prompt Desktop Shortcut on Windows 10

You can add a Command Prompt shortcut to your desktop the same way you add any other shortcut. Once the shortcut is added, you can change its name and icon to your liking.

To start:

  1. Open the Start menu and search for Command Prompt.
  2. Right-click Command Prompt in the search results and select Open file location.

  1. A File Explorer window opens with a Command Prompt shortcut. Here, right-click the Command Prompt shortcut again and select Open file location.

  1. You should now see a file called cmd.exe, which is the Command Prompt executable file. Right-click the cmd.exe file and select Send to > Desktop (create shortcut).

  1. Access your desktop, and you should find a new shortcut called cmd.exe – Shortcut there. Double-click this shortcut to open Command Prompt.

  1. To rename the shortcut, right-click the shortcut, select Rename, enter a new name, and press Enter.

Run the Command Prompt Shortcut With Admin Rights

To run certain commands, you’d need admin privileges in Command Prompt. You can configure your desktop Command Prompt shortcut so that it always opens the tool with admin privileges.

To do this:

  1. Right-click the Command Prompt shortcut on your desktop and select Properties.

  1. On the Properties window, select the Shortcut tab at the top.
  2. In the Shortcut tab, select the button that says Advanced.

  1. A new window opens on your screen. Here, enable the Run as administrator checkbox and select OK at the bottom.

  1. Go back to the Properties window, select Apply and then select OK at the bottom.

  1. Double-click the Command Prompt shortcut, and it should now open with admin privileges.

Create a Keyboard Shortcut to Launch Command Prompt

You can make opening Command Prompt even easier by assigning a keyboard shortcut to the tool’s desktop shortcut. Windows allows you to choose a custom combination of keys for the shortcut.

To assign a shortcut:

  1. Right-click the Command Prompt shortcut on your desktop and select Properties.
  2. Select the Shortcut tab at the top of the Properties window.

  1. In the Shortcut tab, select the Shortcut key field. Know that whatever keyboard shortcut you assign here, Windows will prefix it with Ctrl + Alt.
  2. Press the key that you want to assign to the Command Prompt shortcut. For example, press C. The Shortcut key field should display Ctrl + Alt + C.

  1. Then, select Apply followed by OK at the bottom to save your changes.

Add the Command Prompt Shortcut to the Windows Taskbar

You may want to pin Command Prompt to your taskbar to open the tool with a single click:

  1. Right-click the Command Prompt shortcut on your desktop and select Pin to taskbar.

  1. The tool is now on your taskbar.
  2. To remove this taskbar shortcut, right-click the shortcut and select Unpin from taskbar.

Create a PowerShell Desktop Shortcut on Windows 10

If you use PowerShell, adding PowerShell’s shortcut to your desktop is as easy as adding any other app’s shortcut.

  1. Launch the Start menu and search for Windows PowerShell.
  2. Right-click Windows PowerShell in the search results and select Open file location.

  1. On the following screen, right-click Windows PowerShell and select Open file location.

  1. You should now see powershell.exe. Right-click this file and select Send to > Desktop (create shortcut).

  1. You now have a PowerShell shortcut on your Windows desktop.

Run the PowerShell Shortcut With Admin Rights

If you run commands that require admin privileges, configure the PowerShell shortcut to always open the tool with admin rights.

  1. Right-click the PowerShell shortcut on your desktop and select Properties.

  1. Select the Shortcut tab in Properties.
  2. Select the Advanced button in the Shortcut tab.

  1. In the Advanced Properties window that opens, activate the Run as administrator box and then select OK at the bottom.

  1. Select Apply and then select OK at the bottom of the window.
  2. Your PowerShell shortcut will now always open with admin rights.

Create a Keyboard Shortcut to Launch PowerShell

You can assign a shortcut to the PowerShell desktop so that the tool opens with a keystroke.

  1. Right-click the PowerShell shortcut on your desktop and select Properties.

  1. Select the Shortcut tab in Properties.
  2. Select the Shortcut key field and type the keyboard shortcut you want to use. Keep in mind that your shortcut will be prefixed with Ctrl + Alt.
  3. For example, if you assign P, Windows will treat it as Ctrl + Alt + P.

  1. Select Apply and then select OK at the bottom to save your shortcut.

Add the PowerShell Shortcut to the Windows Taskbar

For quick access, you can add the PowerShell shortcut to your taskbar.

  1. Right-click the PowerShell shortcut on your desktop and select Pin to taskbar.

  1. A PowerShell icon is now added to your taskbar.
  2. To remove this shortcut, right-click the shortcut on the taskbar and choose Unpin from taskbar.

Bonus Tip: Open Command Prompt or PowerShell’s Taskbar Shortcut With a Keyboard Shortcut

By default, Windows 10 assigns a keyboard shortcut to each app on the taskbar. These shortcuts use a numeric system. Here, the app on the farthest left side of the taskbar is numbered one, and then two, three, and so on.

To use this shortcut, you’d press the Windows key and then the number of your app on the taskbar. For example, if Command Prompt is the fifth numbered shortcut on the taskbar, you’d use Windows + 5 to open the utility.

You can drag the icons on the taskbar in any direction (left or right), and their shortcuts will change accordingly.

Related Posts

  • How to Fix a “This file does not have an app associated with it” Error on Windows
  • How to Fix an Update Error 0x800705b4 on Windows
  • How to Resolve “A JavaScript error occured in the main process” Error on Windows
  • How to Fix the Network Discovery Is Turned Off Error on Windows
  • How to Change Folder Icons in Windows

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows movie maker zip
  • Grub2 windows boot manager
  • Сколько весит windows 7 64 бит
  • Как узнать версию net framework в windows 10 cmd
  • Где хранится бэкап windows