Book Image

Microsoft Exchange Server PowerShell Essentials

By : Biswanath Banerjee
Book Image

Microsoft Exchange Server PowerShell Essentials

By: Biswanath Banerjee

Overview of this book

PowerShell has become one of the most important skills in an Exchange administrator's armory. PowerShell has proved its mettle so widely that, if you're not already starting to learn PowerShell, then you're falling behind the industry. It isn't difficult to learn PowerShell at all. In fact, if you've ever run commands from a CMD prompt, then you'll be able to start using PowerShell straightaway. This book will walk you through the essentials of PowerShell in Microsoft Exchange Server and make sure you understand its nitty gritty effectively. You will first walk through the core concepts of PowerShell and their applications. This book discusses ways to automate tasks and activities that are performed by Exchange administrators and that otherwise take a lot of manual effort. Microsoft Exchange PowerShell Essentials will provide all the required details for Active Directory, System, and Exchange administrators to help them understand Windows PowerShell and build the required scripts to manage the Exchange Infrastructure.
Table of Contents (17 chapters)
Microsoft Exchange Server PowerShell Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Using pipelines


A pipeline is a series of cmdlet statements connected through the pipeline (|) character (ASCII 124). Pipelines are used to send the output objects from one command as an input to another command. This can be used in scripts and console to build complex statements.

The output of Get-Service is piped to more command that displays information one screen at a time:

Get-Servince | more

You can use pipelines to build complex queries. For example, the following example will get the output of the Get-Service cmdlet and pipe it to the Where-Object cmdlet that will filter the services whose names match the MSExchange text, and the status is set to Running. The logical and operator is used in this case to combine the two conditions:

Get-Service | Where-Object {($_.Name –like "MSExchange*") –and ($_.Status –eq "Running")}

So far, we saw how to take output from one command and feed it into the next one. Now, let's take it further by adding one more piping. The following statement will get the output of the Get-Service cmdlet and pass it to Where-object where it will filter it for Exchange services, which are stopped, and then it will pass the output using another pipeline to Start-Service cmdlet. So, using this one-line command, you can check which Exchange Services are not running and start them. We have used the—autosize parameter to format the output based on the number of columns and their sizes:

Get-Service | Where-Object {($_.Name –like "MSExchange*") –and ($_.Status –eq "Stopped")} | Start-Service