For instance, the syntax line for the Copy-Item command (copy to you
and me) consumes four lines, and is about as easy to read as the computer
output in the Matrix movies.* But rest assured, it??™s more or less the same as
its DOS counterpart; in other words, this command:
copy c:\stuff\myfile.txt d:\misc
still works as you??™d expect.
Pipelines
So, if PowerShell looks like the Command Prompt, and most of the commands
you know and love work the same, then what??™s the point?
Without drowning you in technical jargon, what sets PowerShell Cmdlets
apart from their Command Prompt counterparts is that they work better
with piping, a means of redirecting the output of one command so that it??™s
used as the input for another. For example, this two-part command:
get-process m* | stop-process
works because the get-process Cmdlet sends (through the pipe) its output (a
list of running processes that start with the letter m) as a structured object. In
turn, the stop-process Cmdlet receives this object and uses it as a list of processes
to stop. In lesser Command Prompts, this information is passed
between commands (piped) as plain text, which means you need to use a
variety of tools (like grep in Unix) to format the output so the receiving command
can process it. (Imagine what this would all sound like if I had left in
the jargon.)
Unfortunately, this particular aspect of PowerShell is a little more hype than
dope. For one, the example command above (taken from Microsoft??™s own
documentation) is pointless, since the following simpler command works
just as well:
stop-process m*
Of course, the downside of this object-oriented model is that the various
data is all typed, and can??™t be easily converted from one type to another.
Pages:
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790