Você está na página 1de 3

TOPIC

about_Objects

SHORT DESCRIPTION
Provides essential information about objects in
Windows PowerShell.

LONG DESCRIPTION
Every action you take in Windows PowerShell occ
urs within the context of
objects. As data moves from one command to the
next, it moves as one or
more identifiable objects. An object, then, is
a collection of data that
represents an item in a namespace. An object is
made up of three types
of data: the object's type, its methods, and it
s properties.

The data about an object's type provides detail


s about what kind of
object it is. For example, an object that repre
sents a file is a
FileInfo object.

An object's method is an action that you can pe


rform on the item that
the object represents. For instance, a FileInfo
object includes a
method that you can use to cause the file to be
copied. That is, when
you invoke the copy method of the object, the f
ile that the object
represents is copied.

An object's property is information about the s


tate of that object. For
example, a FileInfo object includes the length
property, which
specifies the size of the file represented by t
he object.

When working with objects, you can use their me


thods and properties in
your commands to take specific actions and mani
pulate data. This is
especially useful when you combine multiple com
mands into a single
pipeline.

When commands are combined in a pipeline, they


pass information to each
other as objects. When the first command runs,
it sends one or more
objects down the pipeline to the second command
. The second command
receives the objects from the first command, pr
ocesses the objects, and
then passes new or revised objects to the next
command in the pipeline.
This continues until all commands in the pipeli
ne run.

The following example demonstrates how objects


are passed from one
command to the next:

Get-ChildItem c: | where {$_.PsIsContainer


-eq $false} |
Format-List

The first command (Get-ChildItem c:) returns an


object for each item in
the root directory of the file system. Those ob
jects are passed down
the pipeline to the second command (where {$_.P
sIsContainer -eq
$false}). The second command uses the PsIsConta
iner property of the
object to filter the data from the input object
s so that no directories
(containers) are returned. The command then pas
ses the information as
objects to the third command (Format-List), whi
ch displays the contents
of each piped object in a list format.

SEE ALSO
about_Methods
about_Properties
about_Pipelines
Get-Member

Você também pode gostar