Preface
This book is full of immediately usable task-based recipes for managing and maintaining your Microsoft Exchange 2013 environment with Windows PowerShell 3.0 and the Exchange Management Shell. The focus of this book is to show you how to automate routine tasks and solve common problems. While the Exchange Management Shell literally provides hundreds of cmdlets, we will not cover every single one of them individually. Instead, we'll focus on the common, real world scenarios. You'll be able to leverage these recipes right away, allowing you to get the job done quickly, and the techniques that you'll learn will allow you to write your own amazing one-liners and scripts with ease.
What this book covers
Chapter 1, PowerShell Key Concepts, introduces several PowerShell core concepts such as command syntax and parameters, working with the pipeline, and flow control with loops and conditional logic. The topics covered in this chapter lay the foundation for the remaining code samples in each chapter.
Chapter 2, Exchange Management Shell Command Tasks, covers day-to-day tasks and general techniques for managing Exchange from the command line. The topics include configuring manual remote shell connections, exporting reports to external files, sending e-mail messages from scripts, and scheduling scripts to run with the Task Scheduler.
Chapter 3, Managing Recipients, demonstrates some of the most common recipient-related management tasks, such as creating mailboxes, distribution groups, and contacts. You'll also learn how to manage server-side inbox rules, out of office settings, and import user photos into the Active Directory.
Chapter 4, Managing Mailboxes, shows you how to perform various mailbox management tasks that include moving mailboxes, importing and exporting mailbox data, and the detection and repair of corrupt mailboxes. In addition, you'll learn how to delete and restore items from a mailbox, manage the new public folders, and generate some basic reports.
Chapter 5, Distribution Groups and Address Lists, takes you deeper into distribution group management. The topics include distribution group reporting, distribution group naming policies, and allowing end users to manage distribution group membership. You'll also learn how to create address lists and hierarchal address books.
Chapter 6, Mailbox Database Management, shows how to set database settings and limits. Report generation for mailbox database size, average mailbox size per database, and backup status is also covered in this chapter.
Chapter 7, Managing Client Access, covers the managing of ActiveSync, OWA, POP, and IMAP. It also covers the configuration of these components in Exchange 2013. We'll also take a look at controlling connections from various clients, including ActiveSync devices.
Chapter 8, Managing Transport Service, explains the various methods used to control mail flow within your Exchange organization. You'll learn how to create, send, and receive connectors, allow application servers to relay mail, and manage transport queues.
Chapter 9, High Availability, covers the implementation and management tasks related to Database Availability Groups (DAGs). Topics include creating DAGs, adding mailbox database copies, and performing maintenance on DAG members. It also covers the new feature called automatic reseed.
Chapter 10, Exchange Security, introduces the new Role Based Access Control (RBAC) permissions model. You'll learn how to create custom RBAC roles for administrators and end users, and also how to manage mailbox permissions and implement SSL certificates.
Chapter 11, Compliance and Audit Logging, covers the new compliance and auditing features included in Exchange 2013. Topics such as archiving mailboxes and discovery search are covered here, as well as administrator and mailbox audit logging.
Chapter 12, Server Monitoring and Troubleshooting, shows you how to monitor and report on service availability and resource utilization using PowerShell core cmdlets and WMI. Event log monitoring and Exchange server role troubleshooting tactics are also covered.
Chapter 13, Scripting with the Exchange Web Services Managed API, introduces advanced scripting topics that leverage Exchange Web Services. In this chapter, you'll learn how to write scripts and functions that go beyond the capabilities of the Exchange Management Shell cmdlets.
Appendix A, Common Shell Information, is a reference for the variables, scripts, and the filtering functions. These references will help you when writing scripts or running interactive.
Appendix B, Query Syntaxes, is a reference for the Advanced Query Syntax (AQS). Here are lots of different examples that can be used in the real world.
What you need for this book
To complete the recipes in this book, you'll need the following:
PowerShell v3, which is already installed by default on Windows 8 and Windows Server 2012.
A fully operational lab environment with an Active Directory forest and Exchange organization.
Ideally, your Exchange Servers will run Windows Server 2012, but they can run Windows Server 2008 R2, if needed.
You'll need to have at least one Microsoft Exchange 2013 server.
It is assumed that the account you are using is a member of the Organization Management role group. The user account used to install Exchange 2013 is automatically added to this group.
If possible, you'll want to run the commands, scripts, and functions in this book from a client machine. The 64-bit version of Windows 8 with the Exchange 2013 Management Tools installed is a good choice. You can also run the tools on Windows 7. Each client will need some additional prerequisites in order to run the tools, see Microsoft's TechNet documentation for full details.
If you don't have a client machine, you can run the Exchange Management Shell from an Exchange 2013 server.
Chapter 13 requires the Exchange Web Services Managed API version 2.0, which can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=35371.
The code samples in this book should be run in a lab environment and fully tested before deployed into production. If you don't have a lab environment setup, you can download the software from http://technet.microsoft.com/en-us/exchange/. Then build the servers on your preferred virtualization engine.
Who this book is for
This book is for messaging professionals who want to learn how to build real-world scripts with Windows PowerShell 3.0 and the Exchange Management Shell. If you are a network or systems administrator responsible for managing and maintaining the on-premise version of Exchange Server 2013, then this book is for you.
The recipes in this Cookbook touch on each of the core Exchange 2013 server roles, and require a working knowledge of the supporting technologies, such as Windows Server 2008, 2008 R2 or 2012, Active Directory, and DNS.
All of the topics in this book are focused on the on-premises version of Exchange 2013, and we will not cover Microsoft's hosted version of Exchange Online through Office 365. However, the concepts you'll learn in this book will allow you to hit the ground running with that platform since it will give you an understanding of PowerShell's command syntax and object-based nature.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can read the content of an external file into the shell using the Get-Content
cmdlet"
Commands and blocks of code are set as follows:
Get-Mailbox –ResultSize Unlimited | Out-File C:\report.txt
Commands like this can be invoked interactively in the shell, or from within a script or function.
Most of the commands you'll be working with will be very long. In order for them to fit into the pages of this book, we'll need to use line continuation. For example, here is a command that creates a mailbox:
New-Mailbox -UserPrincipalName jsmith@contoso.com ` -FirstName John ` -LastName Smith ` -Alias jsmith ` -Database DB1 ` -Password $password
Notice that the last character on each line is the backtick (`
) symbol, also referred to as the grave accent. This is PowerShell's line continuation character. You can run this command as is, but make sure there aren't any trailing spaces at the end of each line. You can also remove the backticks and carriage returns and run the command on one line. Just ensure the spaces between the parameters and arguments are maintained.
You'll also see long pipeline commands formatted like the following example:
Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,ServerName,Database | Export-Csv c:\mbreport.csv -NoTypeInformation
PowerShell uses the pipe character (|
) to send object output from a command down the pipeline so it can be used as input by another command. The pipe character does not need to be escaped. You can enter the previous command as is, or you can format the command so that everything is on one line.
Any command-line input or output that must be done interactively at the shell console is written as follows:
[PS] C:\>Get-Mailbox administrator | ft ServerName,Database -Auto ServerName Database ---------- -------- mbx1 DB01
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Exchange Management Shell shortcut".
Note
Warnings or important notes appear in a box like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <suggest@packtpub.com>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com>
if you are having a problem with any aspect of the book, and we will do our best to address it.