Command-Line Tips


One cool thing that you may not realize about the PowerShell command-line is that it offers code completion, which is not entirely unlike the Intellisense features in Microsoft Visual Studio or the PrimalSense features in SAPIEN PrimalScript. Of course, PowerShell isn't a graphical application so there are no pop-up menus, but you can get code-completion assistance. For example, open PowerShell and type Get-, then press Tab. The command-line changes to Get-Acl, which is the first cmdlet that matches the first part of what you typed. Press Tab again and you'll see Get-Alias. As you keep pressing Tab, you see the next cmdlet in the list. After selecting a cmdlet, type a space and press Tab again. You'll see a filename (or folder name) that is actually the first file (or folder), alphabetically, from the folder where PowerShell is currently pointed. If PowerShell were pointed to the CERT: drive, which is your certificate store, you'd see CurrentUser or LocalMachine, which are the two subfolders of the certificate store. This is just one small way PowerShell tries to help you out.

Another trick you may have already discovered involves the arrow keys. While the Left and Right keys obviously move the cursor left and right, the Up and Down keys redisplay previous shell commands. This is much like the Cmd shell with which you may be familiar. This is a good way to quickly go back to a past command, modify it if needed, and execute it again.

If you've used the Cmd.exe shell, you may be familiar with this next tip. You can copy and paste between a PowerShell console session and other Windows. Unfortunately, by default it takes too many steps. However, to simplify the process right-click the System menu in the PowerShell window, and then choose Properties. Under Edit Options, check both Quick Edit Mode and Insert Mode. Click OK and save properties for future windows with the same title.

To copy from PowerShell, left-click and drag your mouse in the console window, selecting the text you want. Press Enter. Open Notepad or any other Windows application and paste the text. To paste into the PowerShell console window, select your text from the Windows application then right-click at the PowerShell prompt to paste your text. This is a great way for writing long PowerShell expressions in Notepad or PrimalScript and then try them out.



Windows PowerShell. TFM
Internet Forensics
ISBN: 982131445
EAN: 2147483647
Year: 2004
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net