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
About the Author
About the Reviewer

Writing a basic script

Now, let's use the knowledge that we have gained in the previous sections to write a script, and then we will schedule this script to run using the Windows task scheduler.

Let's try to understand the different sections of this script that will allow us to break the entire script into multiple parts, making it easier for us to understand the logic.

The first part defines parameters accepted by this script. Over here, we have defined the first parameter called $ExportMailbox to be a switch parameter, which is a mandatory one. A switch parameter means it is either true or false. In this case, this parameter has to be present as we have marked it as mandatory. If we use the script without this parameter, it will prompt, and it will fail if we don't specify it. The other two parameters will accept string values; and they are optional.

Next, we have used an If condition, which is true for $ExportMailbox as it is a mandatory parameter. It will initialize two variables. $i will...