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

Writing a basic script


Here is a simple script that will put a DAG member into maintenance mode and display the result of the component states at the end. We have covered the commands in DAG Maintenance section. The first IF statement will check if the target server is a mailbox server; if it is not, it will exit. I have used the Green Foreground color, but feel free to use a color of your choice based on your Exchange Management shell background. The file name used to save this script is the Start-MaintenanceMode.ps1 file. It takes two mandatory parameters: Server and TargetServerFQDN. Here is an example of putting mailbox server Exch2 in the maintenance mode. Exch3 is another mailbox server, which is part of the same DAG01:

<#Start-MaintenanceMode.ps1 –Server Exch2 –TargetServerFQDN Exch3.contoso.com
#===========
#Parameters
#===========
Param
(
    [Parameter(Mandatory=$true,
               ValueFromPipelineByPropertyName=$true,
               Position=0)]
    [string]$Server=$env:COMPUTERNAME...