Chapter 1: PowerShell Key Concepts 7
Introduction 8
Using the help system 9
Understanding command syntax and parameters 13
Understanding the pipeline 17
Working with variables and objects 20
Formatting output 25
Working with arrays and hash tables 28
Looping through items 33
Creating and running scripts 35
Using flow control statements 39
Creating custom objects 43
Creating PowerShell functions 47
Setting up a profile 51
Chapter 2: Exchange Management Shell Common Tasks 55
Introduction 55
Manually configuring remote PowerShell connections 57
Using explicit credentials with PowerShell cmdlets 61
Transferring files through remote shell connections 62
Dealing with concurrent pipelines in remote PowerShell 65
Managing domains or an entire forest using recipient scope 67
Exporting reports to text and CSV files 68
Sending SMTP e-mails through PowerShell 72
Scheduling scripts to run at a later time 75
Logging shell sessions to a transcript 77
Automating tasks with the scripting agent 78
Scripting an Exchange server installation 81
ii
Table of Contents
Chapter 3: Managing Recipients 85
Introduction 86
Adding, modifying, and removing mailboxes 87
Working with contacts 91
Managing distribution groups 93
Managing resource mailboxes 95
Creating recipients in bulk using a CSV file 97
Working with recipient filters 101
Adding and removing recipient e-mail addresses 104
Hiding recipients from address lists 107
Configuring recipient moderation 108
Configuring message delivery restrictions 111
Managing automatic replies and out of office settings for a user 113
Adding, modifying, and removing server-side inbox rules 115
Managing mailbox folder permissions 118
Importing user photos into Active Directory 121
Chapter 4: Managing Mailboxes 125
Introduction 126
Reporting on the mailbox size 127
Working with move requests and performing mailbox moves 129
Mailbox move e-mail notification 134
Importing and exporting mailboxes 136
Deleting messages from mailboxes 141
Managing disconnected mailboxes 144
Generating mailbox folder reports 148
Reporting on mailbox creation time 151
Checking mailbox logon statistics 153
Setting storage quotas for mailboxes 154
Finding inactive mailboxes 155
Detecting and fixing corrupt mailboxes 157
Restoring deleted items from mailboxes 160
Managing public folder mailboxes 162
Reporting on public folder statistics 164
Managing user access to public folders 165
Chapter 5: Distribution Groups and Address Lists 169
Introduction 170
Reporting on distribution group membership 170
Adding members to a distribution group from an external file 172
Previewing dynamic distribution group membership 174
Excluding hidden recipients from a dynamic distribution group 176
iii
Table of Contents
Converting and upgrading distribution groups 179
Allowing managers to modify group membership 181
Removing disabled user accounts from distribution groups 183
Working with distribution group naming policies 185
Working with distribution group membership approval 187
Creating address lists 189
Exporting address list membership to a CSV file 191
Configuring hierarchical address books 193
Chapter 6: Mailbox Database Management 197
Introduction 197
Managing the mailbox databases 198
Moving databases and logs to another location 201
Configuring the mailbox database limits 205
Reporting on mailbox database size 207
Finding the total number of mailboxes in a database 209
Determining the average mailbox size per database 212
Reporting on database backup status 214
Restoring data from a recovery database 217
Chapter 7: Managing Client Access 221
Introduction 221
Managing ActiveSync, OWA, POP3, and IMAP4 mailbox settings 223
Setting internal and external CAS URLs 225
Managing Outlook Anywhere settings 229
Blocking Outlook clients from connecting to Exchange 231
Reporting on active OWA and RPC connections 234
Controlling ActiveSync device access 237
Reporting on ActiveSync devices 239
Chapter 8: Managing Transport Service 243
Introduction 243
Managing connectors 245
Configuring transport limits 248
Allowing application servers to relay mail 250
Managing transport rules and settings 253
Creating a basic disclaimer 260
Working with custom DSN messages 261
Managing connectivity and protocol logs 264
Searching message tracking logs 269
Working with messages in transport queues 273
Searching anti-spam agent logs 278
Implementing a header firewall 282
iv
Table of Contents
Chapter 9: High Availability 285
Introduction 285
Building a Windows NLB cluster for CAS servers 287
Creating a Database Availability Group 291
Adding mailbox servers to a Database Availability Group 293
Configuring Database Availability Group network settings 295
Adding mailbox copies to a Database Availability Group 297
Activating mailbox database copies 300
Working with lagged database copies 302
Reseeding a database copy 304
Using the automatic reseed feature 305
Performing maintenance on Database Availability Group members 309
Reporting on database status, redundancy, and replication 312
Chapter 10: Exchange Security 319
Introduction 319
Granting users full access permissions to mailboxes 320
Finding users with full access to mailboxes 323
Sending e-mail messages as another user or group 325
Working with Role Based Access Control (RBAC) 326
Creating a custom RBAC role for administrators 330
Creating a custom RBAC role for end users 332
Troubleshooting Role Based Access Control 336
Generating a certificate request 338
Installing certificates and enabling services 340
Importing certificates on multiple exchange servers 342
Chapter 11: Compliance and Audit Logging 347
Introduction 347
Managing archive mailboxes 349
Configuring archive mailbox quotas 350
Creating retention tags and policies 352
Applying retention policies to mailboxes 357
Placing mailboxes on retention hold 358
Placing mailboxes on in-place hold 360
Performing a discovery search 363
Enabling mailbox audit logging 366
Generating mailbox audit log reports 368
Configuring Administrator Audit Logging 371
Searching the administrator audit logs 373
v
Table of Contents
Chapter 12: Server Monitoring and Troubleshooting 377
Introduction 378
Managing and monitoring services 379
Verifying server connectivity 383
Working with event logs 385
Reporting on disk usage 388
Checking CPU utilization 391
Monitoring memory utilization 395
Reporting on Exchange Server uptime 397
Troubleshooting the Mailbox role 400
Troubleshooting the Client Access Server role 402
Troubleshooting the Transport service 405
Verifying certificate health 406
Chapter 13: Scripting with the Exchange Web Services Managed API 411
Introduction 411
Getting connected to EWS 413
Sending e-mail messages with EWS 417
Working with impersonation 422
Searching mailboxes 427
Retrieving the headers of an e-mail message 432
Deleting e-mail items from a mailbox 437
Creating calendar items 442
Exporting attachments from a mailbox 447
Appendix A: Common Shell Information 453
Exchange Management Shell reference 453
Properties that can be used with the Filter parameter 459
Properties that can be used with the RecipientFilter parameter 462
Appendix B: Query Syntaxes 465
Advanced Query Syntax 465
Using the word phrase search 466
Using a date range search 468
Using the message type search 469
Using the logical connector search 470
Index 471