Professional Documents
Culture Documents
about_pipelines
SHORT DESCRIPTION
Combining commands into pipelines in the Window
s PowerShell
LONG DESCRIPTION
A pipeline is a series of commands connected by
pipeline operators
(|)(ASCII 124). Each pipeline operator sends the
results of the preceding
command to the next command.
For example,
|
| (FileInfo objects )
| ( .txt )
|
V
Where-Object {$_.length -gt 10000}
|
| (FileInfo objects )
| ( .txt )
| ( Length > 10000 )
|
V
|
| (FileInfo objects )
| ( .txt )
| ( Length > 10000 )
| ( Sorted by length )
|
V
|
| (FileInfo objects )
| ( .txt )
| ( Length > 10000 )
| ( Sorted by length )
| (Formatted in a table )
|
V
Name Length
---- ------
tmp1.txt 82920
tmp2.txt 114000
tmp3.txt 114000
USING PIPELINES
ONE-AT-A-TIME PROCESSING
$services = get-service
format-table -inputobject $servic
es -property name, dependentservices
System.Diagnostics.Process object.
get-process | get-member
TypeName: System.Diagnostics.Pr
ocess
Name Mem
berType Definition
---- ---
------- ----------
Handles Ali
asProperty Handles = Handlecount
Name Ali
asProperty Name = ProcessName
NPM Ali
asProperty NPM = NonpagedSystemMemorySize
...
TypeName: System.Object[]
Name MemberType De
finition
---- ---------- --
--------
Count AliasProperty Co
unt = Length
Address Method Sy
stem.Object& Address(Int32 )
Clone Method Sy
stem.Object Clone()
...
-name <string[]>
Specifies the service names for the serv
ice to be started.
The parameter name is optional. You can
use "-Name" or its alias,
"-ServiceName", or you can omit the para
meter name.
Required? true
Position? 1
Default value
--> Accept pipeline input? true (ByVal
ue, ByPropertyName)
Accept wildcard characters? true
-inputObject <ServiceController[]>
Specifies ServiceController objects repr
esenting the services to be started. Enter
a variable that contains the objects or
type a command or expression that gets the
objects.
Required? false
Position? named
Default value
--> Accept pipeline input? true (ByVal
ue)
Accept wildcard characters? false
Required? true
Position? 2
Default value
Accept pipeline input? true (ByPr
opertyName)
Accept wildcard characters? true
get-itemproperty hklm:\software\mycompany\sales
The results show that the Product registry ent
ry was moved to the Sales key.
PSPath : Microsoft.PowerShell.Core\R
egistry::HKEY_LOCAL_MACHINE\software\mycompany\sal
es
PSParentPath : Microsoft.PowerShell.Core\R
egistry::HKEY_LOCAL_MACHINE\software\mycompany
PSChildName : sales
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Re
gistry
Product : 18
SEE ALSO
about_objects
about_parameters
about_command_syntax
about_foreach