Book Image

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
Book Image

Learning PowerCLI for VMware VSphere

By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the pipeline


In PowerShell, you can use the output of one command as input for another command by using the vertical bar (|) character. This is called using the pipeline. The vertical bar character is called the pipe character. In PowerShell, complete objects pass through the pipeline. This is different from cmd.exe or a Linux shell where only strings pass through the pipeline. The advantage of passing complete objects through the pipeline is that you don't have to perform string manipulation to retrieve property values.

Using the ByValue parameter binding

You have already seen some examples of using the pipeline in previous sections of this book, for example:

PowerCLI C:\> Get-VM | Get-Member

In this example, the output of the Get-VM cmdlet is used as the input for the Get-Member cmdlet. This is much simpler than the following command, which gives you the same result:

PowerCLI C:\> Get-Member -InputObject (Get-VM)

You can see that the Get-Member cmdlet accepts input from the...