TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Page Details
First published by
Mohammad Nizamuddin
(eMicrosoft Community Contributor, Microsoft Partne)
When:
8 Jan 2013 1:02 AM
Last revision by
Maheshkumar S Tiwari
When:
19 Sep 2013 4:38 AM
Revisions:
2
Comments:
1
Options
Original
Wiki
>
TechNet Articles
>
PowerShell – Understanding pipeline and extending pipeline to more than one line
>
Original
PowerShell – Understanding pipeline and extending pipeline to more than one line
You are currently reviewing an older revision of this page.
Go to current version
When writing PowerShell script one command which goes in a long line reduces the readability of the command, this normally happens when you are taking output object of one cmdlet and passing it to another cmdlet.
You would like to extend a long line command in multi-line to improve the readability:-
First let me clarify what does pipeline means in PowerShell, as you know object returned by a cmdlet can be stored in a variable for later use or piped to a subsequent cmdlet as input for the subsequent cmdlet. A pipeline is a channel through which the output of a cmdlet can be passed to following cmdlet, the pipeline is represented by pipe char ‘|’
Here is an example of pipeline: - Output of Get-Service cmdlet which is SPTimerV4 service is piped to the next cmdlet Stop-Service which stops the SpTimerV4 service.
Get-Service SPTimerV4 | Stop-Service
Below are the ways how you can extend the pipeline to more than one line to improve readability.
Use Tick Mark (‘):
You can use tick mark to break the line and continue the command in next line, PowerShell assumes that the subsequent line is the continuation of the current line.
Example:-
Get-Service –DisplayName *SharePoint* |
‘
Stop-Service
Use Pipe Symbol (|) as last character of the line:
When Pipe symbol is the last character of a line, it indicates that the command is not complete so Windows PowerShell continues the command with the subsequent line
Example:-
Get-Service –DisplayName *SharePoint*
|
Stop-Service
Use a left curly brace ({):
Curly braces are normally used to enclose the structure such as expression or a procedure. A left curly brace suggests that a structure follows.
Revert to this revision