Getting started with PowerShell (4): Efficient Use of the interactive Runtime Environment

Source: Internet
Author: User

Multi-purpose Tab key

In the running environment, the Tab key is used to complete the content. In addition to completing sub-directories and sub-files like Cmd, you can also complete the cmdlets, functions, and parameters of PowerShell. This is really useful. For example, you must add ". \ ", otherwise, you will not be able to execute the script even if you have fully typed the script file name. However, after you typed the first few letters of the script file name, press the Tab key, the script will be completely executed. Is it handsome? Note the following two points:

1. The first few letters of the files and commands you typed should be segmented; otherwise, all matching files, folders, and commands may be traversed;

2. Rather than try again, do not make a mistake; otherwise, nothing can be found;

Common Alias

Using Alias is another effective way to improve work efficiency. There are two main reasons:

1. Alias is generally a familiar command method. It is easy to find appropriate commands or to make appropriate commands;

2. The Cmdlet is generally long due to structure issues, and the dash horizontal bar) is not in the letter area. Hitting this key also reduces productivity, while Alias generally has two or three letters, short and good, just to make up for the defects of the Cmdlet.

In addition, there is a principle that has to be mentioned here: Alias should be used as much as possible during interactive work; Alias should be used as little as possible when writing scripts, or even not Alias. This is because when you run commands in interactive mode to complete the work, the entered commands and expected results are only related to the user, and generally do not need to be shared with others. Of course, the efficiency is the case; scripts are generally used for a long time and maintained by many people, making readability more important than efficiency.

Migrate the battlefield from Cmd to PowerShell

The person who wants to contact PowerShell is generally the one who uses Cmd command lines. The tool has been used for a long time and is naturally friendly and unwilling to be put down. However, to keep up with the times and fully benefit from the current achievements, we need to leave the comfort zone and try new things. Here, we need to transfer our main working environment from the Cmd command line to PowerShell.

Generally, using PowerShell is no more complicated than using the Cmd command line. For example, you need to check the IP address of the machine in use. You used to press the Windows key + R key, then Enter cmd, press enter, ipconfig, and press Enter. The entire process takes only a few seconds. What about now? Just replace cmd with powershel, which is also very fast. But sometimes it is a little troublesome. For example, if you used to input dir/ad in the command line to view all subfolders, enter dir |? {$ _. Mode-like "d *"}. There is a little more input, but this is the way to get familiar with this tool. Worst off. If you are anxious to execute a command, but the powershell command cannot be remembered at half past one, enter "cmd/c command" in PowerShell ", for example, run cmd/c dir/ah to find hidden files in the current directory. In short, you have to play PowerShell more and be familiar with it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.