You are previewing Microsoft Exchange Server PowerShell Cookbook - Third Edition.
O'Reilly logo
Microsoft Exchange Server PowerShell Cookbook - Third Edition

Book Description

Over 120 recipes to help you manage and administrate Exchange Server 2013 Service Pack 1 with PowerShell 5

In Detail

Microsoft Exchange Server 2013 is a complex messaging system. Windows PowerShell 5 can be used in conjunction with Exchange Server 2013 to automate and manage routine and complex tasks to save time and money and eliminate errors.

Starting by going through key PowerShell concepts and the Exchange Management Shell, this book will get you automating tasks that used to take hours in no time. Diving deeper, you will then manage your mailbox database, client access, and your transport servers with simple but effective scripts.

This book finishes with advanced recipes on Exchange Server problems, such as managing distribution groups and maintaining high availability and security.

What You Will Learn

  • New features and capabilities of PowerShell 5 and Exchange Server 2013 SP1

  • Get to grips with the core PowerShell concepts required to master the Exchange Management Shell, such as pipelining, working with objects, formatting output, and writing scripts

  • Use simple PowerShell scripts and commands to get powerful effects

  • Generate detailed reports, send the output of commands in e-mail messages, and schedule scripts to run automatically

  • Import, export, move mailboxes, and delete messages from mailboxes using the command line

  • Configure transport server settings such as mail relay, tracking logs, transport rules, delivery reports, and more

  • Manage mailbox and public folder databases

  • Downloading the example code for this book. 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.

    Table of Contents

    1. Microsoft Exchange Server PowerShell Cookbook Third Edition
      1. Table of Contents
      2. Microsoft Exchange Server PowerShell Cookbook Third Edition
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
          3. Instant updates on new Packt books
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There’s more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. PowerShell Key Concepts
        1. Introduction
          1. Performing some basic steps
        2. Using the help system
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Getting help with cmdlets and functions
          4. See also
        3. Understanding command syntax and parameters
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Understanding the pipeline
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Working with variables and objects
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Variable expansion in strings
            2. Strongly typed variables
        6. Working with arrays and hash tables
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        7. Looping through items
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        8. Creating custom objects
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Using debugger functions
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        10. Understanding the new execution policy
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        11. Working with Desired State Configuration
          1. How to do it...
          2. How it works...
          3. See also
        12. Using the Save-Help function
          1. How to do it...
          2. How it works...
          3. See also
        13. Working with script repositories
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
      9. 2. Exchange Management Shell Common Tasks
        1. Introduction
          1. Performing some basic steps
        2. Manually configuring remote PowerShell connections
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using explicit credentials with PowerShell cmdlets
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Transferring files through remote shell connections
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Managing domains or an entire forest using the recipient scope
          1. How to do it...
          2. How it works...
          3. There's more...
        6. Exporting reports to text and CSV files
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Sending SMTP e-mails through PowerShell
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Sending messages with attachments
            2. Sending command output in the body of a message
          4. See also
        8. Scheduling scripts to run at a later time
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Logging shell sessions to a transcript
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Automating tasks with the scripting agent
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Using multiple cmdlets with the OnComplete API
          5. See also
        11. Scripting an Exchange server installation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      10. 3. Managing Recipients
        1. Introduction
          1. Performing some basic steps
        2. Adding, modifying, and removing mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Setting the Active Directory attributes
          4. See also
        3. Working with contacts
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Managing distribution groups
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Managing resource mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Converting mailboxes
          4. See also
        6. Creating recipients in bulk using a CSV file
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Taking it a step further
          5. See also
        7. Working with recipient filters
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Understanding variables in filters
          4. See also
        8. Adding and removing recipient e-mail addresses
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Hiding recipients from address lists
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Configuring recipient moderation
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Configuring message delivery restrictions
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        12. Managing automatic replies and Out of Office settings for a user
          1. How to do it...
          2. How it works...
          3. There's more...
        13. Adding, modifying, and removing server-side inbox rules
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        14. Managing mailbox folder permissions
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        15. Importing user photos into Active Directory
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
            1. Taking it a step further
          5. See also
      11. 4. Managing Mailboxes
        1. Introduction
          1. Performing some basic steps
        2. Reporting on the mailbox size
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Working with move requests and performing mailbox moves
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Removing the move requests
            2. Moving the archive mailboxes
            3. Moving the mailboxes in batches
            4. Moving mailboxes with corrupt items
          4. See also
        4. E-mail notification on mailbox moves
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        5. Importing and exporting mailboxes
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Importing data into mailboxes
            2. Taking it a step further
          4. See also
        6. Deleting messages from mailboxes
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Running reports before deleting data
            2. Deleting messages in bulk
          4. See also
        7. Managing disconnected mailboxes
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        8. Reporting on mailbox creation time
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Setting storage quotas for mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Finding inactive mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Detecting and fixing corrupt mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        12. Restoring deleted items from mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        13. Managing public folder mailboxes
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        14. Reporting on public folder statistics
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        15. Managing user access to public folders
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
      12. 5. Distribution Groups and Address Lists
        1. Introduction
          1. Performing some basic steps
        2. Reporting on distribution group membership
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Adding members to a distribution group from an external file
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Previewing dynamic distribution group membership
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Excluding hidden recipients from a dynamic distribution group
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Converting and upgrading distribution groups
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Allowing managers to modify group membership
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Removing disabled user accounts from distribution groups
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        9. Working with distribution group naming policies
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Working with distribution group membership approval
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Creating address lists
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        12. Exporting address list membership to a CSV file
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        13. Configuring hierarchical address books
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      13. 6. Mailbox Database Management
        1. Introduction
          1. Performing some basic steps
        2. Managing the mailbox databases
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Understanding the automatic mailbox distribution
            2. Taking it a step further
          4. See also
        3. Moving databases and logs to another location
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Manually moving databases
            2. Taking it a step further
          4. See also
        4. Configuring the mailbox database limits
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Taking it a step further
          4. See also
        5. Reporting on mailbox database size
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Finding the total number of mailboxes in a database
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Determining the average mailbox size per database
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Reporting on database backup status
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Restoring data from a recovery database
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Understanding target mailbox identity
            2. Learning about other useful parameters
            3. Understanding the mailbox restore request cmdlets
            4. Taking it a step further
          4. See also
      14. 7. Managing Client Access
        1. Introduction
          1. Performing some basic steps
        2. Managing ActiveSync, OWA, POP3, and IMAP4 mailbox settings
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Setting internal and external CAS URLs
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Command syntax for the remaining virtual directories
            2. Taking it one step further
          4. See also
        4. Managing the Outlook Anywhere settings
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Blocking Outlook clients from connecting to Exchange
          1. How to do it...
          2. How it works...
          3. There's more…
        6. Reporting on active OWA and RPC connections
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Controlling ActiveSync device access
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Reporting on ActiveSync devices
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      15. 8. Managing Transport Servers
        1. Introduction
          1. Performing some basic steps
        2. Managing connectors
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        3. Configuring transport limits
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        4. Allowing application servers to relay mail
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        5. Working with custom DSN messages
          1. How to do it...
          2. How it works...
          3. There's more…
        6. Managing connectivity and protocol logs
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Parsing log files
        7. Searching message tracking logs
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Taking it a step further
          4. See also
        8. Working with messages in transport queues
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        9. Searching anti-spam agent logs
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        10. Implementing a header firewall
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Configure the Edge Transport server role
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      16. 9. High Availability
        1. Introduction
          1. Performing some basic steps
        2. Building a Windows NLB cluster for CAS servers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more…
            1. Taking it a step further
          5. See also
        3. Creating a Database Availability Group
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        4. Adding mailbox servers to a Database Availability Group
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Configuring Database Availability Group network settings
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Renaming and removing DAG networks
        6. Adding mailbox copies to a Database Availability Group
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        7. Activating mailbox database copies
          1. How to do it...
          2. How it works...
          3. There's more…
          4. See also
        8. Working with lagged database copies
          1. How to do it...
          2. How it works...
          3. There's more...
        9. Reseeding a database copy
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Using the automatic reseed feature
          1. How to do it...
          2. How it works...
          3. See also
        11. Performing maintenance on Database Availability Group members
          1. How to do it...
          2. How it works...
          3. There's more...
        12. Reporting on database status, redundancy, and replication
          1. How to do it...
          2. How it works...
          3. There's more…
            1. Understanding switchover and failover metrics
            2. Understanding replication metrics
          4. See also
      17. 10. Exchange Security
        1. Introduction
          1. Performing some basic steps
        2. Granting users full access permissions to mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Finding users with full access to mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
        4. Sending e-mail messages as another user or group
          1. How to do it...
          2. How it works...
          3. There's more...
        5. Working with Role Based Access Control
          1. How to do it...
          2. How it works...
          3. There's more…
            1. RBAC for end users
          4. See also
        6. Creating a custom RBAC role for administrators
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Creating a custom RBAC role for end users
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Troubleshooting RBAC
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Generating a certificate request
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Installing certificates and enabling services
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Importing certificates on multiple Exchange servers
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      18. 11. Compliance and Audit Logging
        1. Introduction
          1. Performing some basic steps
        2. Managing archive mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        3. Configuring archive mailbox quotas
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Creating retention tags and policies
          1. How to do it...
          2. How it works…
          3. There's more…
            1. Understanding default tags
          4. See also
        5. Applying retention policies to mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Placing mailboxes on Retention Hold
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Placing mailboxes on In-Place Hold
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Performing a discovery search
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Configuring administrator audit logging
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        10. Searching the administrator audit logs
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        11. Configuring S/MIME for OWA
          1. How to do it...
          2. How it works...
          3. See also
      19. 12. Scripting with the Exchange Web Services Managed API
        1. Introduction
          1. Performing some basic steps
        2. Getting connected to EWS
          1. How to do it...
          2. How it works...
          3. There's more...
          4. Certificates matter
        3. Sending e-mail messages with EWS
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        4. Working with impersonation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Searching mailboxes
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        6. Retrieving the headers of an e-mail message
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        7. Deleting e-mail items from a mailbox
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        8. Creating calendar items
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        9. Exporting attachments from a mailbox
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      20. A. Common Shell Information
        1. Exchange Management Shell reference
          1. Commonly-used shell variables
          2. Commonly-used type accelerators
          3. Scripts available in the $Exscripts directory
        2. Properties that can be used with the -Filter parameter
        3. Properties that can be used with the -RecipientFilter parameter
      21. B. Query Syntaxes
        1. Advanced Query Syntax
        2. Using the word phrase search
          1. Examples
        3. Using a date range search
          1. Examples
        4. Using the message type search
          1. Examples
        5. Using the logical connector search
          1. Examples
      22. Index