本文共 2412 字,大约阅读时间需要 8 分钟。
powershell快捷键
A hard working admin is constantly opening and closing multiple programs to get work done. When you’re working in PowerShell, we can use aliases to make switching to a new program as fast as possible.
努力工作的管理员会不断打开和关闭多个程序以完成工作。 当您在PowerShell中工作时,我们可以使用别名来尽可能快地切换到新程序。
We’ll first need to find the folder location of the program executable. We’re using Notepad in our example, which is located in “C:WindowsSystem32notepad.exe”
我们首先需要找到程序可执行文件的文件夹位置。 我们在示例中使用的是记事本,该示例位于“ C:WindowsSystem32notepad.exe”中
Next we’ll open PowerShell and enter:
接下来,我们将打开PowerShell并输入:
new-item alias:np -value C:WindowsSystem32notepad.exe
新项目别名:np -value C:WindowsSystem32notepad.exe
This states that we are assigning the Alias Name “np” to the program Notepad.exe. Once the command is run, it outputs the verification of our assigning the alias to the program.
这表明我们正在将别名“ np”分配给程序Notepad.exe。 一旦命令运行,它将输出我们为程序分配别名的验证。
Now we can type our new shortcut “np” in the PowerShell prompt, hit enter,
现在,我们可以在PowerShell提示符下键入新的快捷方式“ np” ,按Enter,
and our program opens right up!
我们的程序马上打开!
If we need to remove the alias shortcut in the future, we’ll just type:
如果将来需要删除别名快捷方式,则只需键入:
remove-item alias:np
删除项目别名:np
If you need your alias to resist deletion, then you can add one of two available options to the end of the alias creation command:
如果需要别名来阻止删除,则可以在别名创建命令的末尾添加两个可用选项之一:
This option will allow you to change the association of the alias or delete it during the session, but you will have to add -force to the end of the command.
此选项将允许您更改别名的关联或在会话期间将其删除,但是您必须在命令末尾添加-force 。
new-item alias:np -value C:WindowsSystem32notepad.exe –options “ReadOnly”
新项目别名:np -value C:WindowsSystem32notepad.exe –选项“只读”
This option will make the alias unable to be altered or deleted while the session is open.
此选项将使在打开会话时无法更改或删除别名。
new-item alias:np -value C:WindowsSystem32notepad.exe –options “Constant”
新项目别名:np -value C:WindowsSystem32notepad.exe –选项“常量”
To view all the current aliases, type:
要查看所有当前别名,请键入:
Set-Location alias: Get-ChildItem *
设置位置别名:Get-ChildItem *
Creating shortcuts using aliases is pretty easy, and can be very useful. However, the alias definition will be removed the next time you open a PowerShell session, so if you want to make an alias permanent, you’ll have to modify your PowerShell Profile.
使用别名创建快捷方式非常容易,并且非常有用。 但是,下次打开PowerShell会话时,别名定义将被删除,因此,如果要使别名永久化,则必须修改PowerShell配置文件。
翻译自:
powershell快捷键
转载地址:http://sxywd.baihongyu.com/