文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 电脑基础知识 > Chapter 1. The PowerShell Console
侵权投诉

Chapter 1. The PowerShell Console

Redirecting: Storing Information in Files

If you’d like to redirect the result of a command to a file, you can use the redirection symbol ">":

Help > help.txt (Enter)

The information won't appear in the console but will instead be redirected to the specified file. You can then open the file.However, opening a file in PowerShell is different from opening a file in the classic console:

help.txt (Enter)

The term "help.txt" is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.At line:1 character:8+ help.txt <<<<

If you only specify the file name, PowerShell will look for it in all folders listed in the PATH environment variable. So to open afile, you will have to specify its absolute or relative path name. For example:

.\help.txt (Enter)

Or, to make it even simpler, you can use Tab-completion and hit (Tab) after the file name:

help.txt(Tab)

The file name will automatically be completed with the absolute path name, and then you can open it by pressing (Enter):

& "C:\Users\UserA\help.txt" (Enter)

You can also append data to an existing file. For example, if you'd like to supplement the help information in the file with helpon native commands, you can attach this information to the existing file with the redirection symbol ">>":

Cmd /c help >> help.txt (Enter)

If you'd like to directly process the result of a command, you won't need traditional redirection at all because PowerShell canalso store the result of any command to a variable:

$result$result

= Ping 10.10.10.10Reply from 10.10.10.10: bytes=32 time<1ms TTL=128Reply from 10.10.10.10: bytes=32 time<1ms TTL=128Reply from 10.10.10.10: bytes=32 time<1ms TTL=128Reply from 10.10.10.10: bytes=32 time<1ms TTL=128Ping statistics for 10.10.10.10:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:Minimum = 0ms, Maximum = 0ms, Average = 0ms

Variables are universal data storage and variable names always start with a "$". You'll find out more about variables inChapter 3.

Summary

PowerShell is part of the operating system starting with Windows 7 and Server 2008 R2. On older operating systems such asWindows XP or Server 2003, it is an optional component. You will have to download and install PowerShell before using it.The current version is 2.0, and the easiest way to find out whether you are using the most current PowerShell version is tolaunch the console and check the copyright statement. If it reads "2006", then you are still using the old and outdatedPowerShell 1.0. If it reads "2009", you are using the correct version. There is no reason why you should continue to usePowerShell 1.0, so if you find it on your system, update to 2.0 as soon as possible. If you wanted to find out your current

PowerShell version programmatically, output the automatic variable $psversiontable (simply by entering it). It not only tells youthe current PowerShell version but also the versions of the core dependencies. This variable was introduced in PowerShellversion 2.0, so on version 1.0 it does not exist.

The PowerShell console resembles the interactive part of PowerShell where you can enter commands and immediately getback results. The console relies heavily on text input. There are plenty of special keys listed in Table 1.1.

KeyMeaning

(Alt)+(F7)Deletes the current command history

(PgUp), (PgDn)Display the first (PgUp) or last (PgDn) command you used in current session(Enter)Send the entered lines to PowerShell for execution(End)Moves the editing cursor to the end of the command line(Del)Deletes the character to the right of the insertion point(Esc)Deletes current command line

(F2)Moves in current command line to the next character corresponding to specified character(F4)Deletes all characters to the right of the insertion point up to specified character(F7)Displays last entered commands in a dialog box

(F8)

Displays commands from command history beginning with the character that you already entered in thecommand line

上一页第11页

你可能喜欢

热门文档

相关文档

  • 1、PowerShell帮助篇

    该 cmdlet 可复制的特定项 取决于可用的 Windows PowerShell 提供程序。例如,与 FileSystem 提供程序一 起使用时,它可以复制文件和目录;与 Registry 提供程序一起...

  • PowerShell基础知识之一

    PowerShell 基础知识之一本 Blog 所发表的所有"原创文章", 未经许可, 禁止以任何形式进行转载. 作者: Edengundam(马涛) 如果要学一门语言, 你就必须对语言的...

  • PowerShell 1.0 用户指南

    PowerShell 1.0 用户指南_互联网_IT/计算机_专业资料。PowerShell 1.0 用户指南Windows PowerShell 语言快 速参考为不同类型的系统提供的本机支持 Windows ...

  • PowerShell 1.0 入门指南

    本文档介绍了 Windows PowerShell 的基本概念和功能,并提供了一些使用 Windows PowerShell 进行系统管理的建议方法。 目录 Windows PowerShell 入门版权声明 ... 8 Win...

  • PowerShell_ISE_v3

    Console Pane Go to Script Pane Cycle through command history Scroll to the...$psISE.CurrentPowerShellTab Defines the properties of the current PowerShell ...

  • PowerShell_Examples_v3

    Windows PowerShell 3.0 Examples Created by http://powershellmagazine.com How...The webpage is entirely Javascript-based, so you can access the console ...

  • Windows PowerShell 1.0 入门

    启动 Windows PowerShell 若要从“开始”菜单启动 Windows PowerShell,请依次单击“开始”“所有程序” Windows 、、 PowerShell 1.0 和 Windows PowerShell。 若要...

  • powershell命令大全

    向 Windows PowerShell 对象的实例中添加用户定义的自定义成 将一个或多个 ...Console Export-Counter Export-CSV Export-FormatData Export-ModuleMember Export-...

  • Windows Server 2008 R2 Powershell 命令的使用

    Key Message The Active Directory module for Windows PowerShell in Windows ...Console (MMC) snap-ins to connect to their Active Directory domains and ...

  • 第10章 Windows_PowerShell脚本编程

    方法如下:首先启 动安装好的Powershell,在命令窗口中输入如下命 令并回车: PS C:\> Export-Console myconsole ? 10.2.3 配置PowerShell ? ? 配置Windows ...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email